Greetings everyone.
little by little my app is starting to get shaped and now I'm on my next step.
so, I have a group that contains several controls/graphics inside.
first, I created all the handles to scroll the group using drag & drop.
Now, I'm going to implement the handles to drag & drop the controls within the group.
The first thing I noticed was ... "hmm I'm going to need "another" on MouseUp function...."
so, my question is:
- may I have multiple instances of the same handler in the same script? (I presume not, but just want to make sure...)
- since I have multiple different actions that will use the same handlers (like mouseUp, mouseDown, etc...) what do you think it's the best way to manage this ?
many thanks for any provided help
cheers,
- Miguel
Multiple instances of same function - how to manage it
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 328
- Joined: Mon Dec 05, 2011 5:34 pm
- Contact:
Re: Multiple instances of same function - how to manage it
First of all read up on "The Message Path" in Livecode. It will explain what you can do. There are lots of references to it on the forums, do a bit of a search first.
In basic terms though - you cannot have multiple copies of a handler within the 'same' script, but you can have same named handlers in the script for various parts of your objects (group, button, etc)
It would be best for you to go through some of the lessons on the RunRev site, because this aspect is one of the first covered!
Cheers,
Dave
In basic terms though - you cannot have multiple copies of a handler within the 'same' script, but you can have same named handlers in the script for various parts of your objects (group, button, etc)
It would be best for you to go through some of the lessons on the RunRev site, because this aspect is one of the first covered!
Cheers,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.
Visit http://electronic-apps.info for released App information.
Re: Multiple instances of same function - how to manage it
Hi.
Only the first handler in any script with a similar name will be executed. This is useful in development, where you can test multiple variants by either commenting out the others or by moving the one of interest to the top.
But your question is far more fundamental, and that is what Dave was alluding to. The work of distinguishing multiple programmatic pathways is always managed within a single handler, usually with "if-then" or "switch" control structures, very basically:
on mouseUp --your handler
if someProperty then doThis --one way
else doThat --the other way
end mouseUp
There are others.
There has never been a case, probably, in fact, no case can even be envisioned, that cannot be managed with the standard tools available in all programming languages, LC being no different. Give us an example of what you have in mind, generically, and let us see how to move this forward. The way you framed your question makes me certain that it will be easier than you currently think.
Craig Newman
Only the first handler in any script with a similar name will be executed. This is useful in development, where you can test multiple variants by either commenting out the others or by moving the one of interest to the top.
But your question is far more fundamental, and that is what Dave was alluding to. The work of distinguishing multiple programmatic pathways is always managed within a single handler, usually with "if-then" or "switch" control structures, very basically:
on mouseUp --your handler
if someProperty then doThis --one way
else doThat --the other way
end mouseUp
There are others.
There has never been a case, probably, in fact, no case can even be envisioned, that cannot be managed with the standard tools available in all programming languages, LC being no different. Give us an example of what you have in mind, generically, and let us see how to move this forward. The way you framed your question makes me certain that it will be easier than you currently think.
Craig Newman
Re: Multiple instances of same function - how to manage it
Thank you all for your replies.
Looks like there's no "special" way to do in in livecode, so I'll stick with the traditional ways
cheers
- Miguel
Looks like there's no "special" way to do in in livecode, so I'll stick with the traditional ways

cheers
- Miguel
Re: Multiple instances of same function - how to manage it
Miguel... I think what you might be looking for is 'behaviors'... read about them in the dictionary.