Behaviours qustion

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Behaviours qustion

Post by phaworth » Mon Mar 08, 2010 10:26 pm

I have a lot of objects in my app that would benefit from behaviour scripts instead of having the code local to them. There's one detail that has stopped me from doing that so far. Occasionally, an object will need to need to execute some extra code unique to itself after the behaviour script has executed. What's the best way to handle that situation?
Thanks,
Pete

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Behaviours qustion

Post by mwieder » Tue Mar 09, 2010 12:12 am

Use the dispatch command in the behavior script:

button 1 (the behavior button):

Code: Select all

on mouseUp
  put "hello" after msg
  dispatch "morestuff"
end mouseUp
button 2:

Code: Select all

on morestuff
  put "more stuff" after msg
end morestuff
if there's a morestuff handler in the child control it will be called, otherwise it will just be passed on.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”