Instantiaing Grouped Controls - Templates - Responsive

Terry Judd terry.judd at unimelb.edu.au
Thu Jun 8 01:14:16 EDT 2017


Hi BR - for me it depends on how many instances of the control I’m likely to need on the screen. If I only ever display one at a time then I usually include it as a shared group and place it on any card that might require it and show/hide, populate and layer it dynamically as required. If I need multiple instances of it then then I do the copy thing and discard and instances when I leave the screen. I don’t usually create these sorts of multi-part controls from scratch and I haven’t used text only stacks so I don’t really have any advice there. I also love the flexibility of datagrids so I tend to use them (on both mobile and desktop) wherever I need a list-style control, no matter how simple it is.

HTH,

Terry...

On 8/06/2017 2:42 pm, "use-livecode on behalf of Sannyasin Brahmanathaswami via use-livecode" <use-livecode-bounces at lists.runrev.com on behalf of use-livecode at lists.runrev.com> wrote:

    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 | About |Instructions |Privacy Policy etc…  all to be dynamically loaded and 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
    
    4 objects:
    
    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
    
    on resizeControl
    lock screen
    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
    unlock screen
    end resizeControl
    
    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?
    
    OR
    
    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
    
    BR
    
    _______________________________________________
    use-livecode mailing list
    use-livecode at lists.runrev.com
    Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
    http://lists.runrev.com/mailman/listinfo/use-livecode
    





More information about the use-livecode mailing list