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
-
glenn9
- Posts: 234
- Joined: Wed Jan 15, 2020 10:45 pm
Post
by glenn9 » Fri Jan 31, 2020 11:59 am
Hi, is it possible to 'fire' a pre-selected item from a ComboBox from the script of another object on the same card?
Have tried various permutations and excerpts (in an 'on' script) from the standard menuPick script to get this to work but no success so far!
grateful for any hints or suggestions
many thanks,
Code: Select all
(-- with reference to field "A")
on rawkeyup
put field "A" into field "B"
actOnSelectedComboxItem
end rawkeyup
on actOnSelectedComboxItem
-- (have tried to insert a menuPick script here so that field "B" is amended by the selected combobox item)
end actOnSelectedComboxItem
-
Klaus
- Posts: 14194
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Fri Jan 31, 2020 12:13 pm
Hi Glenn,
I confess, I don't have the slightest idea what you are trying to do, "put fld A into fld B" is the only part I understand!
Some hints:
You can set the LABEL of a combobox and we can trigger a menu by setting its "menuhistory".
Best
Klaus
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10320
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Fri Jan 31, 2020 3:20 pm
Hi.
Are you asking how to invoke a menu-style button remotely? If so, the trick is to:
Code: Select all
on mouseUp
click at the loc of btn "yourMenuButton"
end mouseUp
But there is a slight difference with a combo box, in that the "clickable" area is located only at the right side of that control. So:
Code: Select all
click at (the right of btn "yourMenuButton") - 3 & "," & item 2 of the loc of btn "yourMenuButton"
Craig
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10320
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Fri Jan 31, 2020 3:27 pm
Hi again.
Or are you trying to remotely invoke one of the menuItems within a combo box? In that case, make a new combo box and another button. The combo box will already have three menuItems, "Choice 1", etc. In the script of the comboBox:
Code: Select all
on menuPick tMenu
if tMenu = "choice 2" then answer random(999)
end menuPick
In the script of the other button:
Code: Select all
on mouseUp
send "menuPick" && "choice 2" to btn 1
end mouseUp
Write Back.
Craig
-
glenn9
- Posts: 234
- Joined: Wed Jan 15, 2020 10:45 pm
Post
by glenn9 » Sat Feb 01, 2020 8:54 am
Klaus wrote: ↑Fri Jan 31, 2020 12:13 pm
Hi Glenn,
I confess, I don't have the slightest idea what you are trying to do, "put fld A into fld B" is the only part I understand!
Some hints:
You can set the LABEL of a combobox and we can trigger a menu by setting its "menuhistory".
Best
Klaus
Hi Klaus,
Apologies, I think what I was asking whether it was to invoke a menupick item from a combobox within a message handler?
Kind regards,
Glenn
-
glenn9
- Posts: 234
- Joined: Wed Jan 15, 2020 10:45 pm
Post
by glenn9 » Sat Feb 01, 2020 8:55 am
dunbarx wrote: ↑Fri Jan 31, 2020 3:27 pm
Hi again.
Or are you trying to remotely invoke one of the menuItems within a combo box? In that case, make a new combo box and another button. The combo box will already have three menuItems, "Choice 1", etc. In the script of the comboBox:
Code: Select all
on menuPick tMenu
if tMenu = "choice 2" then answer random(999)
end menuPick
In the script of the other button:
Code: Select all
on mouseUp
send "menuPick" && "choice 2" to btn 1
end mouseUp
Write Back.
Craig
Thanks Craig, I'll give that a try and feedback.
Kind regards,
Glenn
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10320
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sat Feb 01, 2020 5:00 pm
Please do.
You may be interested in a spin-off thread I started, derived from this one:
viewtopic.php?f=9&t=33603.
It may have some bearing on what you do when remotely invoking comboBox handlers.
Craig
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7392
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Sat Feb 01, 2020 7:14 pm
The cleanest way to do this is to use menuhistory. See the dictionary for that term, part of which is:
When you set the menuHistory property, a menuPick message is sent to the button.
If the button's menuMode is "comboBox", setting its menuHistory also changes the button's label to the new menu item.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10320
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sat Feb 01, 2020 7:49 pm
Jacque.
MenuHistory works fine except when the menuItem of interest is already selected in the comboBox. Then the message is not generated from the button.
As Richard points out in:
viewtopic.php?f=9&t=33603.
That is done on purpose. I posted a "fix", assuming anyone wants to know. This behavior is peculiar to combos, it does not fail in any of the other menu-style buttons.
Craig
-
glenn9
- Posts: 234
- Joined: Wed Jan 15, 2020 10:45 pm
Post
by glenn9 » Mon Feb 03, 2020 7:54 am
Many thanks everyone for all the replies, this has helped me solve this issue and it all works as expected now.
Kind regards,
Glenn