Front and Back Scripts on Mobile

Richard Gaskin ambassador at fourthworld.com
Sat Jul 2 14:47:03 EDT 2016


Sannyasin Brahmanathaswami wrote:

 > Ralph wrote:
 >> I had this problem way back.  Mark noted that that the scroller
 >> messages are sent to the stack that created the scroller.
 >
 > Does it makes sense to file this as an enhancement request?

I believe a more accurate description is that the scrollerDidScroll 
message is sent to the *script* that created the scroller, which many 
not necessarily be a stack.

In my case it's a backscript, and it works well.

It seemed painfully tedious to even think about typing scroller 
instantiation code for every controls that needs it, so I don't. 
Instead, a backscript scans controls during preOpenCard and anything 
that needs a scroller gets one instantiated for it (along the way it 
also turns off scrollbars, since of course those are only useful on 
desktop).

Because the backscript created the mobile scroller, it's also the 
recipient of the scrollerDidScroll message, where that handler obtains 
the mobileControlTarget to know which physical object to scroll, which 
it then does.

All that takes place in a backscript, so the thing being scrolled needs 
no code at all.

In this respect it seems a very xTalk way of working:

When my LC objects have scrollbars, the user can scroll them.  This 
happens automatically on desktop (via the engine) and mobile (via my 
backscript) alike.  I never need to think about it.  Whether it's 
running on desktop in the IDE or on my mobile device I get identical 
behavior.

Just as LiveCode minimizes differences between desktop platforms, for 
many basic things a little time spent generalizing mobileControlWhatever 
handlers into a backscript can also minimize differences between desktop 
and mobile.

Moving as much mobile-specific code as practical into a factored 
backscript like this has helped me regain the value of choosing an 
xTalk, by minimizing the differences between development and runtime. 
LiveCode is, after all, truly live code.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list