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
-
Mag
- VIP Livecode Opensource Backer

- Posts: 802
- Joined: Fri Nov 16, 2012 10:51 pm
Post
by Mag » Mon Apr 07, 2014 11:31 am
I try to set a behavior for an option menu and noting seems to happen
Code: Select all
set the behavior of button "chooseAction" to the long id of button "ActionPopup" of card 1 of stack "TM-CodeLibrary"
Also, can't see the behavior field in the Inspector for the Option menu so I suspect that I can't set it... I need to have the same behavior for an option button in two cards and would be great to not to have to repeat the code twice...

-
Klaus
- Posts: 14199
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Mon Apr 07, 2014 11:43 am
Hi Mag,
that's how LC works and the syntax is correct!
Enter this in the message box and see what you get:
put the behavior of button "chooseAction"
Best
Klaus
-
Mag
- VIP Livecode Opensource Backer

- Posts: 802
- Joined: Fri Nov 16, 2012 10:51 pm
Post
by Mag » Mon Apr 07, 2014 11:51 am
Thank you Klaus!
Done the test. It seems as if LC does not want to communicate about it, or maybe the empty result is a message too (as told by the first axiom on communication by Paul Watzlawick "One Cannot Not Communicate")
Anyway, if I write wrong the name of the button I get the (correct) error:
Message execution error:
Error description: Chunk: no such object
Hint: chooseActionxy
-
Attachments
-

-
Klaus
- Posts: 14199
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Mon Apr 07, 2014 11:54 am
-
Mag
- VIP Livecode Opensource Backer

- Posts: 802
- Joined: Fri Nov 16, 2012 10:51 pm
Post
by Mag » Mon Apr 07, 2014 11:58 am
Yes, also with answer command.
Code: Select all
on mouseUp
try
answer the behavior of button "chooseAction"
catch e
answer "Error:" && e
end try
end mouseUp
PS
And no errors raised.
-
Attachments
-

-
bn
- VIP Livecode Opensource Backer

- Posts: 4174
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Mon Apr 07, 2014 12:39 pm
Hi Mag,
have a look at this stack.
It sets the behavior of 2 option menu buttons.
Kind regards
Bernd
-
Attachments
-
- setBehaviorOfOptionMenu.livecode.zip
- (1.14 KiB) Downloaded 131 times
-
Mag
- VIP Livecode Opensource Backer

- Posts: 802
- Joined: Fri Nov 16, 2012 10:51 pm
Post
by Mag » Mon Apr 07, 2014 2:35 pm
Thank you Bernd, when I saw that in your stack the set behavior command works fine, I tought that the problem could be the reference in another card, so I tried to replaced "card 1" with the short name of the card and this worked!
So, this works:
Code: Select all
set the behavior of button "chooseAction" to the long id of button "ActionPopup" of card "Codes" of stack "TM-CodeLibrary" -- works
...and this don't wrk:
Code: Select all
set the behavior of button "chooseAction" to the long id of button "ActionPopup" of card 1 of stack "TM-CodeLibrary" -- don't work
-
Klaus
- Posts: 14199
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Mon Apr 07, 2014 3:19 pm
Ah, good to know, thank you!
-
Mag
- VIP Livecode Opensource Backer

- Posts: 802
- Joined: Fri Nov 16, 2012 10:51 pm
Post
by Mag » Mon Apr 07, 2014 4:46 pm
Thanks to your contribute to get the solution.