I've done it both ways but usually only create controls on the fly when
there are only a few objects (two or three usually.) Anything more complex,
I use a template group and copy that instead. It's nearly instantaneous. I
did a mobile app that copied a group dozens of times in a preOpenCard
handler and there was no discernable delay.
I'd like to hear from the team about what's involved, but my theory is that
it takes more time to create, place, and setup multiple controls than to
just duplicate an existing group. The scripts are easier to read and much
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On June 7, 2017 11:44:55 PM Sannyasin Brahmanathaswami via use-livecode
We are in need of an "info-text" control which we can use "everywhere"
instead of reinventing this in each stack/ module in our app. for Help |
shown on demand.
Different contexts require a different size.
Thanks to Richard's gentle prodding and logic I dove enthusiastically into
the learning curve on responsive UI code for LC.. using the Sheep Herder lesson
Our use case is also very simple. A control for displaying info/text
1) background image (wont' suffer visually from distortion)
2) bkgnd "mask" graphic (goes underneath a field)
3) info-text field
4) widget with SVG close "X out"path, top right..
I put this script in the group "info-display"… it works just fine. Yay!
mission accomplished for a) responsive control
set the rect of img "info-bkgnd-img" to the rect of me
set the width of grc "info-field-bkgnd" to the width of me * .87
set the height of grc "info-field-bkgnd" to the height of me * .87
set the width of fld "info-text" to the width of me * .80
set the height of fld "info-text" to the height of me * .80
set the loc of img "info-bkgnd-img" to the loc of me
set the loc of grc "info-field-bkgnd" to the loc of me
set the loc of fld "info-text" to the loc of me
set the right of widget "close-info" to the right of fld "info-text"
set the bottom of widget "close-info" to the top of grc "info-field-bkgnd" - 5
set the loc of me to the loc of this card
So far, I'm sure this is baby talk for most of you.
But the next question is
b) about best strategy for instantiation.
1) does it make sense to build this dynamically as needed from script using
"create" and then you put this "create control" script into a library? It
has the advantage of no binary object, so you can keep it in your text only
"stacks" .livecodescript, but could be slow?
2) is it faster (on Android or iOS especially) to create it as a template
group then use
copy grp "info-display" of card 1 of stack "dialog-templates" to this card
What has your experience led you to choose as your best practice and why
and how do you do it?
Similarly we have small "lists" Indices… that are typically rows of grouped
controls. Using data grid would be overkill in most contexts… so the
default is to create a "row" as a group, duplicate this and then group all
those rows as a single scrolling group.
so this is a similar pattern: use a template and copy the group? or
instantiate them dynamically from script? Which is better/faster? IYHO
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your subscription