Case Study: Behaviors Failing - Can't set break points

Todd Geist todd at geistinteractive.com
Tue Dec 27 12:36:53 EST 2011


Hello,

I just ran into this issue and I thought I would share it. I thought I was
loading my Behavior's into memory before using them but I wasn't.  Here is
what it looked like when it was failing.

I have some buttons that have behaviors set on them.  When you
control-click on them and look at Send Message, the commands that are
associated with the behavior are there. So, I thought, the button is
clearly linked to it's behavior. However using Dispatch to send the message
results in "unhandled". It was not seeing the behavior's handlers.

If I use the Send form I can see that the message is sent to the Button,
but is not picked up by the Behavior, just the Button. Even if there is no
handler for the message in the button. I can tell this by stepping through
with the debugger.  The debugger goes to the button's Script ( not the
behavior's script ) even though the script is empty.  It never makes it on
to the behavior.

I also noticed that I couldn't set Break Points in the behavior scripts in
the debugger when this condition happened.  They just didn't work.

In all cases, I can it by simply resetting the behavior to itself, like so:

*set *the behavior of tControl to the behavior of tControl


So whats the deal? The button appears to be linked to the behavior? But I
can't send it messages?  And I can't set break points in the Behavior
scripts.

Well the problem is that the behaviors are not in memory when the buttons
that use them are placed into memory.  I thought that they were because I
was loading the stack containing the Behaviors as part of the PreOpenCard
in my first stack.  So the Behaviors were in a second stack.  And they were
being referenced by the first stack.

I think the docs point this out, but I was confused by the apparent
linking, and the fact that I thought loading on PreOpenCard or PreOpenStack
would be enough.  But its not.

I am including behaviors in a Library stack, instead of embedding them into
a the stacks that use them. These are pure code Behaviors, no UI.  And they
are part of the larger feature set provided by the library.  I wanted to be
able to keep the library and it's behavior's separate. So either I will
have to build a launcher file that just loads the library first or build in
re-linking, which may not be a bad thing anyway.

???????????

Todd



More information about the Use-livecode mailing list