Using Behaviors for Triggering UI Design - Run Time
Mark Wieder
mwieder at ahsoftware.net
Wed Mar 30 17:50:50 EDT 2016
On 03/30/2016 01:07 PM, Sannyasin Brahmanathaswami wrote:
> I tested this:
>
> 1) create script only stack with this script (this works if run from a button on the card and a direct reference to the field name)
>
> command centerTextVertically
> put the formattedheight of me into tTotalTextHeight
> put ( the height of me - tTotalTextHeight ) / 2 into tTopBottomMargins
> end centerTextVertically
>
> 2) save that script only stack as "sv_field-behaviors.livecodescript"
>
> 3) go to a field --> set behavior --> choose stack --> I see that stack "sv_field-behaviors" available.
>
> 4) set the behavior of the field to that stack
>
> First Puzzle:
>
> In the message box I run
> "centerTextVertically"
> Nothing happens: the text in the field doesn't move (should get a new top margin)
> Why not?
I think of behavior scripts as private backscripts. So in your case
you're setting the behavior of a field, but then you're going to the
message box to try invoking a handler in a behavior script, and that
handler can't be seen from anywhere except your field. Try
send "centerTextVertically" to field <nameOfField>
another way to do this would be to also set the behavior of the message
box field to the same behavior script, but that way lies madness.
--
Mark Wieder
ahsoftware at gmail.com
More information about the use-livecode
mailing list