Instantiaing Grouped Controls - Templates - Responsive
Alex Tweedly
alex at tweedly.net
Thu Jun 8 17:55:11 EDT 2017
On 08/06/2017 22:37, Richard Gaskin via use-livecode wrote:
> Alex Tweedly wrote:
>
> > On 08/06/2017 20:20, Richard Gaskin via use-livecode wrote:
> >> If you're committed to a script-only stack there's no decision to
> >> make: every control must be instantiated dynamically, because a
> >> script-only stack contains the stack script only, no objects.
> >>
> > Well, not quite "every control".
> >
> > You could :
> > - if the relevant template control/group exists - copy it
> > - if not, create it dynamically, and then copy it
> >
> > This way
> > - the stack can be script-only
> > - most instantiations take minimal time
>
> True, to the degree that your app uses non-script-only stacks, you
> won't need to do everything in script only. :)
>
No, I'm actually doing this all within a script-only stack.
It's a behaviour stack, which is used as a behaviour attached to groups
in the main app stack (which could be binary or script-only). The
behaviour is defined to create controls (actually, groups) as requested
by the main stack - which basically sets up a list of needed controls,
and then calls a handler in the behaviour.
So something vaguely like ....
on preOpenCard
settheEditingMode ofgrp"grp1"ofmetoFALSE
settheSpec ofgrp"grp1"ofmetogSpec
dispatch"buildGroup"togrp"grp1"
...
and within 'buildgroup' it does the
check for the template group existing, create it (from an internal
default set of properties) if needed
This also (I think) allows for the app stack to pre-define the template
groups ahead of time, thereby pre-empting the creation of the groups
within the behaviour stack. Haven't actually done that yet, or fully
considered the problems doing so will create - but it's a loophole I'm
leaving myself in case I need it :-)
-- Alex.
More information about the use-livecode
mailing list