Page 1 of 1
Change Option Menu SELECTION via Script?
Posted: Thu Oct 08, 2020 1:25 pm
by cmhjon
Hi all,
I have an option menu with the following menu items:
Please Select:
Option 1
Option 2
Option 3
Suppose the user selects "Option 2" from the menu. I need to be able to "reset" the option menu back to "Please Select:" via script but I cannot find a way to do this. I can GET the selection of the option menu but I cannot SET it via script. I can set the LABEL of it but that doesn't change the SELECTION of it. The menuLines and menuHistory commands don't seem to be what I want either.
I'm sure it's something simple but I cannot seem to find the answer here or in the dictionary.
Thanks,
Jon
Re: Change Option Menu SELECTION via Script?
Posted: Thu Oct 08, 2020 1:51 pm
by dunbarx
Hi.
There are two ways to "set" a menu-style button.
Code: Select all
set the menuHistory of btn "yourButton" to 1
set the label of btn "yourButton" to "Please Select"
These work differently, but after all is said and done, do the same thing. But it is instructive to play with them, since they open other possibilities for you when fooling around with pulldowns, option buttons, etc.
Craig
Re: Change Option Menu SELECTION via Script?
Posted: Thu Oct 08, 2020 2:19 pm
by cmhjon
Hi Craig,
Thank you for the reply. It would appear that the menuHistory command does in fact do the trick. After testing the command, the SELECTION shows correctly. The label command by itself does not work as the SELECTION still shows "Option 2" as the selected item.
Best regards,
Jon
dunbarx wrote: ↑Thu Oct 08, 2020 1:51 pm
Hi.
There are two ways to "set" a menu-style button.
Code: Select all
set the menuHistory of btn "yourButton" to 1
set the label of btn "yourButton" to "Please Select"
These work differently, but after all is said and done, do the same thing. But it is instructive to play with them, since they open other possibilities for you when fooling around with pulldowns, option buttons, etc.
Craig
Re: Change Option Menu SELECTION via Script?
Posted: Thu Oct 08, 2020 2:49 pm
by dunbarx
cmJohn
Ah, now I see what you wanted. Yes, setting the label only shows the value of the displayed text in the optionMenu. Surely go with the menuHistory, since it actually changes the state of a menu-style button, as if you invisibly clicked and reset that button, and not just changed the displayed text.
Both actions may have their own uses, however.
Craig
Re: Change Option Menu SELECTION via Script?
Posted: Thu Oct 08, 2020 2:58 pm
by dunbarx
Hi again.
The label command by itself does not work as the SELECTION still shows "Option 2" as the selected item.
Not sure what you mean by this. If you simply set the label of your option button, the displayed text will be "Please Select:" but the menuHistory will remain as it was when the user actually selected a menuItem. These are two different properties, and can coexist, even if they structurally seem to be at odds with each other.
But it will not visibly remain as "Option 2". Right?
Craig
Re: Change Option Menu SELECTION via Script?
Posted: Thu Oct 08, 2020 3:09 pm
by cmhjon
Hi Craig,
Setting the LABEL will visually change the button to say "Please Select:" but it does not change its SELECTION. When my app does all its magic, it gets the SELECTION of the button in question.
Thank you,
Jon

Re: Change Option Menu SELECTION via Script?
Posted: Thu Oct 08, 2020 5:27 pm
by dunbarx
You did mention, and loudly, "SELECTION" right at the outset. I got sidetracked. Glad the menuHistory was the cure.
Craig