fullscreenmode and rect of a substack on mobile device ?

Richard Gaskin ambassador at fourthworld.com
Mon Aug 20 00:45:30 EDT 2018


Brahmanathaswami wrote:
 > re Geometry: You keep telling us this again and again, but you never
 > provide an example.

Given how many years most of the members of this list have been 
scripting, it hadn't occurred to me that would be useful.  Here's a 
simple example that illustrates the basics, then extended for reuse:


Consider a Note app.  At the top is a navbar that spans the width of the 
device at 60 px tall; below is a field for the user to type in; centered 
below that is a "Save" button.

This is in the card script:

on resizeStack x,y
   set the rect of grp "Navbar" to 0,0,x,60
   set the rect of fld "Main" to 0,the bottom of grp "Nav",x,y-100
   set the loc of btn "Save" to (item 1 of the loc of this cd, y-40)
end resizeStack

On mobile OSes the resizeStack message is sent when the stack is first 
opened, and again when changed by the user changing the device orientation.


Suppose the Navbar group has three objects within it: a button at left 
and another at right, with a label field filling the space in the middle.

You could add a couple lines for those in the card's resizeStack handler 
shown above, but you might reuse the group elsewhere so it would be 
useful to keep the code within the group.

Just put this in the Navbar group script:

on resizeControl
    set the right of btn "RightSide" to the right of me - 10
    set the rect of fld "Label" to the right of btn "LeftSide", \
       0, the left of btn "RightSide", 60
end resizeControl

The resizeControl message is sent to a group whenever the group is 
resized by any means, whether interactively with the pointer tool or via 
any script that changes the group's rect.

If you have a lot of controls of the same type you probably already use 
behavior scripts for those, so you can put the resizeControl handler in 
the behavior script so every object of that type uses it.

-- 
  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