Page 1 of 1
Combobox actions
Posted: Fri Jan 31, 2020 11:59 am
by glenn9
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
Re: Combobox actions
Posted: Fri Jan 31, 2020 12:13 pm
by Klaus
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
Re: Combobox actions
Posted: Fri Jan 31, 2020 3:20 pm
by dunbarx
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
Re: Combobox actions
Posted: Fri Jan 31, 2020 3:27 pm
by dunbarx
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
Re: Combobox actions
Posted: Sat Feb 01, 2020 8:54 am
by glenn9
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
Re: Combobox actions
Posted: Sat Feb 01, 2020 8:55 am
by glenn9
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
Re: Combobox actions
Posted: Sat Feb 01, 2020 5:00 pm
by dunbarx
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
Re: Combobox actions
Posted: Sat Feb 01, 2020 7:14 pm
by jacque
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.
Re: Combobox actions
Posted: Sat Feb 01, 2020 7:49 pm
by dunbarx
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
Re: Combobox actions
Posted: Mon Feb 03, 2020 7:54 am
by glenn9
Many thanks everyone for all the replies, this has helped me solve this issue and it all works as expected now.
Kind regards,
Glenn