Converting scripts in stacks to script only stack behaviors

Trevor DeVore lists at mangomultimedia.com
Sun Feb 5 20:41:32 EST 2017


ieOn Sun, Feb 5, 2017 at 12:03 PM, Sannyasin Brahmanathaswami via
use-livecode <use-livecode at lists.runrev.com> wrote:

>
> 2) building UI from script: every now and the notion passes by that
> perhaps building UI from script has advantages of  the LC WSIWIG model. I
> was  intrigued in your to see in the background in sublime text, you had a
> handler that built some of the UI.  perhaps all of it for that dialog box?
> So the question then becomes when, where and why do we make a decision to
> go the route to build UI by script? I guess the one obvious answer is that
> you want to put the UI under git control so that we have, as you put it
> "fine-grained control over changes, edits, history" etc.
>

Personally I don't like building UI from script and I very rarely do it in
my projects. The code you saw probably set properties of the controls that
already existed on the card. I prefer to lay out the UI in the LiveCode
IDE. With Levure adding stack files won't cause any conflicts. Each stack
is an independent file and the file that specifies which stacks to load is
a text file. If I am testing standalone settings then I do my testing and
then reset the file to the last commit. No need to stash the changes or
commit them.

My hope is that at some point LC will get a single file, text based file
format for stacks that can be used while authoring. My goal is to keep the
"live" aspect of LiveCode while gaining the benefits of version control
software and really powerful text editors. If I'm creating controls in
script I have to recreate the stack each time I want to move a control
around or add a control.


> I wonder if there are other criteria besides that. Possibly building UI be
> script may be better suited to responsive design, since, in the end, if you
> want responsive geometry, you will end up writing those scripts anyway.
> The only thing missing being the default init props for the control (which
> we normally would create in the IDE) so one must as well "create button"
> and set the default init buttons in the script. Actually it would be pretty
> easy to create the button in WSIWIG and have a small tool to write out the
> initial props that you could then turn into a script.
>

Whether or not you create your UI in script won't affect the code you would
write to make a design responsive. Creating responsive UI in LiveCode isn't
that difficult. If you look at your design you can probably splice it up
into rectangles. If my UI is made up of four primary rectangles then I have
four primary groups. My card script resizes those four groups. The
resizeControl handler in each group is responsible for resizing the
controls in that particular group. Within each primary group you can
continue to splice up the contents into more rectangles, creating groups
and writing more resizeControl handlers. I find that this approach makes
the resizing code more manageable as there is less code at each level.

-- 
Trevor DeVore
Outcome & ScreenSteps
www.outcomeapp.io     -     www.screensteps.com



More information about the use-livecode mailing list