Behavior Nightmare
Scott Rossi
scott at tactilemedia.com
Sun Feb 14 18:55:59 EST 2010
Recently, Sivakatirswami wrote:
> Now, I'm not sure what you mean by "card-level behaviors falling thru to
> stack-level behaviors" but from one point of view it makes sense that
> the behavior cannot be found, because the button that contains the
> behavior is not really in the message path as we normally understand the
> message path. In fact, I could have sworn that the nature of behaviors
> not being in the message path was part of their "charm" so to speak...
> i.e. you would deliberaty keep certain handlers segregated from the msg
> path by having them be behaviors.
The following works on my end and appears to operate counter to what you
say.
- Create new stack "maintest".
- Create substack of maintest named "subtest".
- Create a button in stack subtest named "b1". Script:
on mouseUp
answer theMsg()
end mouseUp
- Create another button in stack subtest named "b2". Script:
function theMsg
return "abc 123"
end theMsg
- Go back to stack maintest. Set the behavior of the current card to long
id of btn b1; set the behavior of stack maintest itself to long id of btn
b2.
Click the card in the main stack. You should see the "abc 123" message
above. Note the script will fail if you remove the behavior assigned to the
main stack or the card in the main stack.
If behaviors are indeed essentially object-level backscripts, then I think
it makes sense that object-level behaviors "fall through" to
card/stack-level behaviors -- this is consistent with card/stack scripts
handling any messages that go unhandled by objects.
Regards,
Scott Rossi
Creative Director
Tactile Media, UX Design
More information about the use-livecode
mailing list