Option Menu
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 244
- Joined: Wed May 11, 2011 7:50 pm
- Location: Southern California
Option Menu
I would like to see if and how I can stop an option-menu from changing its value based on a variable being set without disabling the Optio Menu button.
In other words, I am setting the option-Menu value elsewhere and if the user clicks on the down arrow, i want the option-menu value to remain what it is set to until I change a variable that will allow the Option-Menu to then change via a click select.
My preference is to NOT disable the button.
In other words, I am setting the option-Menu value elsewhere and if the user clicks on the down arrow, i want the option-menu value to remain what it is set to until I change a variable that will allow the Option-Menu to then change via a click select.
My preference is to NOT disable the button.
Clarence Martin
chipsm@themartinz.com
chipsm@themartinz.com
-
- VIP Livecode Opensource Backer
- Posts: 9662
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Option Menu
Hi.
Not sure what you mean.
You can certainly set the menuHistory of a menu-style button remotely. This has nothing to do with disabling that menu button. You can simulate, under script control, the clicking on a menu-style button as well:
Clicking on the down arrow does nothing to such a button or its menuHistory unless you tell it to.
Please give step-by-step instructions on what you are thinking/
Craig Newman
Not sure what you mean.
You can certainly set the menuHistory of a menu-style button remotely. This has nothing to do with disabling that menu button. You can simulate, under script control, the clicking on a menu-style button as well:
Code: Select all
click at the loc of btn "yourOptionButton"
Please give step-by-step instructions on what you are thinking/
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Option Menu
Hi chipsm,
If this is the case you may use
Best regards
Jean-Marc
Do you mean "label" ?option-menu value
If this is the case you may use
Code: Select all
local sMYVar = "TheSame"
on menupick pItem
set the label of me to sMYVar
end menupick
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9662
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Option Menu
Setting the label of a menu style button will indeed display that text. But it does not change the contents of the button, so the available menuItems remains the same. It is certainly may be useful sometimes to do that.
But is that what you meant? In other words, is:
So "value" (yours) is not the contents, but the text displayed?
In that case Jean-Marc makes a point, that the visible label is possible to set even though the menuItems, and therefore the menuHistory, is unchanged.
Craig
But is that what you meant? In other words, is:
the same asi want the option-menu value to remain what it is set to
Is "value" in your statement the same as the contents of the button? It is the contents, in a return delimited list, that determines the displayable choices (the menuItems) of a menu button."I want the contents of the menu button to remain unchanged, but to display some other text temporarily"
So "value" (yours) is not the contents, but the text displayed?
In that case Jean-Marc makes a point, that the visible label is possible to set even though the menuItems, and therefore the menuHistory, is unchanged.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Option Menu
Hi,
I wondered in which case we could need such feature and I remember i used this to keep label "Font" in a menu instead the name font.
Not sure that was clever but I choosed this way for one kid who couldn't accept label change.
Best
Jean-Marc
I wondered in which case we could need such feature and I remember i used this to keep label "Font" in a menu instead the name font.
Not sure that was clever but I choosed this way for one kid who couldn't accept label change.
Best
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9836
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Option Menu
Code: Select all
-- Replaces the list of options in an option button
-- while preserving the selected item, if the current
-- item is present in the new list. Note the use of
-- lockMessages here, needed when setting menuHistory
-- to avoid triggering a menuPick message as would
-- normally happen when menuHistory is changed.
on SetOptionText pObj, pList
lock screen
put the label of pObj into tLabel
set the text of pObj to pList
put lineoffset(tLabel, pList) into tOffset
lock messages
set the menuhistory of pObj to tOffset
unlock messages
unlock screen
end SetOptionText
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
-
- VIP Livecode Opensource Backer
- Posts: 9662
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Option Menu
All good stuff.
If one wants to present a "title" in a menu button, one can:
1- set the label of the button to the title independently, the button contents reserved for "working" menuItems.
2- set the first line of the contents to the desired title, and select only the remainder. One can manage to lose that first line of the contents and restore it as needed, so it does not appear in the actual dropDown.
I like # 1.
Craig
If one wants to present a "title" in a menu button, one can:
1- set the label of the button to the title independently, the button contents reserved for "working" menuItems.
2- set the first line of the contents to the desired title, and select only the remainder. One can manage to lose that first line of the contents and restore it as needed, so it does not appear in the actual dropDown.
I like # 1.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9836
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Option Menu
The challenge with using label alone is that it doesn't update the menuHistory, so the next time the user clicks on it the menu item matching the label is not selected (or on Mac, centered the control).
Using the menuHistory property also sets the label, but with the added benefit of updating the internal record of the currently-selected item, so a subsequent click presents the menu with the hilite as expected.
Using the menuHistory property also sets the label, but with the added benefit of updating the internal record of the currently-selected item, so a subsequent click presents the menu with the hilite as expected.
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
-
- VIP Livecode Opensource Backer
- Posts: 9662
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Option Menu
Richard.
All true. Its is just a matter of how much management is required, and the benefit/hassle ratio.
Craig
All true. Its is just a matter of how much management is required, and the benefit/hassle ratio.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9836
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Option Menu
True, but if given a handler to do it, the task becomes a short one-liner.
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