Hi Scott et al,

The 'after' handler in the behavior script will be executed even if the control 
script itself contains an 'on' handler which forgets to 'pass' the message. 
This is really useful for custom controls where you want to allow the developer 
to implement standard message handlers but ensure the control instance returns 
to a normal state.

Let's say you have your own implementation of a button control.
Your behavior script would handle 'before mouseDown' to turn on the hilited 
appearance, and handle 'after mouseUp' and 'after mouseRelease' to turn off the 
hilited appearance. Now the developer can simple handle 'on mouseUp' to execute 
his business logic, and doesn't have to remember to include a 'pass mouseUp' to 
ensure the appearance is restored.

At first I was skeptical about behaviors, as I could do everything I needed 
using frontscripts and backscripts. Its convenience was in having all code in 
one place, but there were still waysd for the custom control user to mess 
things up (by not passing messages). So thanks to the addition of 'before' and 
'after' message handlers and chained behaviors, this feature has really matured 
and everyone should use it :)

Jan Schenkel.
=====
Quartam Reports & PDF Library for LiveCode
www.quartam.com

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La 
Rochefoucauld)

--------------------------------------------
On Tue, 3/18/14, Scott Rossi <sc...@tactilemedia.com> wrote:

 Subject: Re: before vs on in behavior scripts
 To: "LiveCode Mail List" <use-livecode@lists.runrev.com>
 Date: Tuesday, March 18, 2014, 7:54 PM
 
 I didn't realize it until just now,
 but this is the order of events:
 
 before mouseUp
    answer "A"
 end mouseUp
 
 on mouseUp
    answer "B"
 end mouseUp
 
 after mouseUp
    answer "C"
 end mouseUp
 
 
 Really cool stuff for custom behaviors, but I'm still trying
 to come up
 with a nifty use for the "after" event.
 
 Regards,
 
 Scott Rossi
 Creative Director
 Tactile Media, UX/UI Design
 
 
 
 
 On 3/18/14 7:44 PM, "Scott Rossi" <sc...@tactilemedia.com>
 wrote:
 
 >How are you determining that "on" isn't working? 
 Is it possible that "on"
 >is executing immediately after "before"?
 >
 >Placing the following in a behavior script works fine
 here:
 >
 >before mouseUp
 >   answer "A"
 >end mouseUp
 >
 >on mouseUp
 >   answer "B"
 >end mouseUp
 >
 >
 >If you need some kind of alternate behavior to take
 place after "before"
 >that isn't "on", you might consider "after".  I
 know, it's a lot of
 >prepositions ...
 >
 >Regards,
 >
 >Scott Rossi
 >Creative Director
 >Tactile Media, UX/UI Design
 >
 >
 >
 >
 >On 3/18/14 4:33 PM, "Devin Asay" <devin_a...@byu.edu>
 wrote:
 >
 >>All,
 >>
 >>If a button has a behavior attached to it, and the
 behavior script has a
 >>'before mouseUp' handler, can the behavior script
 also have a 'on
 >>mouseUp' handler?
 >>
 >>I could swear the answer was yes; I thought I had
 done that before, but
 >>now when I try it, it doesn't work. (In LC 6.5.x.
 and 6.6.0RC2). Instead
 >>I have to put the 'in mouseUp' in the button's
 script.
 >>
 >>Of course I might be completely missing the point of
 'before' and 'after'
 >>handlers. Wouldn't be the first time.
 >>
 >>Regards,
 >>
 >>Devin
 >>
 >>
 >>Devin Asay
 >>Office of Digital Humanities
 >>Brigham Young University
 >>
 >>_______________________________________________
 >>use-livecode mailing list
 >>use-livecode@lists.runrev.com
 >>Please visit this url to subscribe, unsubscribe and
 manage your
 >>subscription preferences:
 >>http://lists.runrev.com/mailman/listinfo/use-livecode
 >>
 >
 >
 >
 >_______________________________________________
 >use-livecode mailing list
 >use-livecode@lists.runrev.com
 >Please visit this url to subscribe, unsubscribe and
 manage your
 >subscription preferences:
 >http://lists.runrev.com/mailman/listinfo/use-livecode
 >
 
 
 
 _______________________________________________
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage
 your subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to