Instantiaing Grouped Controls - Templates - Responsive
Sannyasin Brahmanathaswami
brahma at hindu.org
Tue Jun 13 03:44:13 EDT 2017
Mark Waddingham wrote:
This might have been mentioned somewhere else in this thread, but its
probably worth repeating if so as a group with clipsToRect true, and a
resizeControl handler makes a good base for a custom control.
BR: indeed confirmed
just by setting that one property for the group. the very first script I wrote to attempt this "responsive business"
works, because the coord system is now "me" or the rect of the group which is really what we want.
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 * .95
set the height of grc "info-field-bkgnd" to the height of me * .95
set the width of fld "info-text" to the width of me * .85
set the height of fld "info-text" to the height of me * .85
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 grc "info-field-bkgnd" -8
set the top of widget "close-info" to the top of grc "info-field-bkgnd" +10
set the loc of me to the loc of this card
unlock screen
end resizeControl
@Richard who wrote:" Another key change is when "resizeControl" is sent: historically
that was only sent to controls when resized with the pointer tool,
but in recent versions that message is sent to groups whenever
anything changes their rect, even other scripts."
OK yes… this does work, I was thinking it was broken because of the wonky behavior of the group shifting to the rect of the union of child objects. I probably could have set a break point on the resizeControl handler.. but didn't think of that until just now.
on mouseUp
set the rect of grp "display-info" to 50,50,400,400
# this is just to set a base coords = a square for "me"
# later set to the card loc
send "resizeControl" to grp "display-info"
#hacky bit in case clutzy fingers moved the control in dev
# the resizeControl does not fire, but the the control shifts to topleft ,50,50
# so we force it…
end mouseUp
OK this is very cool… next trick…I forcing myself to see how far I can separate code from the actual binary stack into lib's and behaviors. so that nothing but "little triggers" remain in the binary GUI.livecode stack; fascinating.
More information about the use-livecode
mailing list