Tried a few variations in an attempt to
find a way of using the same code for
a number of buttons without having to
repeat the code in each button handler.
Is there a way to have one line of code
in each "mouseUp" handler which directs
to common code elsewhere?
Expect it might need 'with message' to
pass the click to the common code but
haven't been able to find something that
works.
Common Handler for a number of Buttons
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Common Handler for a number of Buttons
Life is just a bowl of cherries.
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
You could put this in each button:
And then put this in your card script:
But that's a lot of work, since you'd have to copy and paste that handler into each button. I'm too lazy for that.
So alternatively you could put a mouseUp handler right in the card script, provided you have some way to distinguish the buttons you want to share the behavior.
Let's assume you have a custom property in each of these buttons named "uClass", with a value of "SpecialButton". Then you could have a mouseUp handler in the card script (or anywhere else later in the message path) like this:
Code: Select all
on mouseUp
DoSomething
end mouseUp
Code: Select all
on DoSomething
--- stuff goes here
end DoSomething
So alternatively you could put a mouseUp handler right in the card script, provided you have some way to distinguish the buttons you want to share the behavior.
Let's assume you have a custom property in each of these buttons named "uClass", with a value of "SpecialButton". Then you could have a mouseUp handler in the card script (or anywhere else later in the message path) like this:
Code: Select all
on mouseUp
if the uClass of the target is "SpecialButton" then
DoSomething
else
pass mouseUp
end if
end mouseUp
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn