Using Behaviors for Triggering UI Design - Run Time

Sannyasin Brahmanathaswami brahma at hindu.org
Wed Mar 30 16:07:32 EDT 2016


@ Richard: doc on Git still leaves this use of stacks as behaviors quite opaque for someone coming to it with no background.   I suspect we only need about 5 more key sentences to get us to "aha! so that's how it works!"

Ditto Bill's question.

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?

Missing key: how the msg path works

Second Puzzle:
  - go back to the field I had created... behavior is set as expected: "stack sv_field-behaviors"
  - create new field, go to behaviors, choose stack: that stack does not appear

So this goes back to Bill's question.

Obviously we would have to at least open the "sv_field-bahaviors.livecodescript"  if we want to apply it to another field... but then if we save and quit and reboot the stack

If we do not load the stack somewhere in a preopenstack or card handler.. is the behavior even available?



Answers need to be appended to this paragraph in the dict entry on GIT.

"The value of the <behavior> <property> is a <object reference|reference>
to a <button> or <stack> containing the script to
use.  The format stored in the object it's assigned to is similar to a
<id(property)|long ID>.  The main difference is that where a long ID includes
the full path to the <stack file>, the form stored in the <behavior>
includes only the stack <name>, allowing the reference to continue to
work after the stack file has been moved to another computer. If you
set the <behavior> to a long ID, LiveCode converts it to a rugged form
without the stack <file path>."

And, once we get the above clear:

-- why doesn't the  behavior "hear" the command from the msg box?
-- how do we auto "fire" commands in behaviors set in fields of a card? so that the "me" reference is the field? Put another way: I want to trigger commands in behaviors set in different controls (fields, buttons, graphics, images)  on a card, in the preopenstack or open card or preopencard handler, how would we do that?


More information about the use-livecode mailing list