Re: Modifying Drop-Down Menus on the fly
Hi from sunny Brittany, Thanks to Eric, Phil, Beda and especially Tore. I was so used to using keywords in button definitions to modify button parameters, that I didn't even look up "Menu" in the dictionary (Can't see the wood for the trees ?) Tore gave me little script routines which I can adapt to my requirements (great stuff !) Beda asked me a question in return (I said I could modify script "cases" with no problems) - a little vague You can change the script of a button completely with the command : set the script of button "abc" to field "xyz" (or a preset variable). Some of my menu button scripts contain "case" commands (which is what I meant .). I change script content in my fields ** and buttons very often, to do rather tortuous things (which I will not describe here !) Now I am starting to do the same with "Drop-Down" menus. This is just the beginning . ** Beda, you can define a script for a field, lock the field and it works like a button when you click on it (it can be useful !) Best Regards to all -Francis ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Modifying Drop-Down Menus on the fly
What you are looking for is: set the text of button “myMenu” to “myMenuList” This can be called in a variety of handlers, at the latest in a mouseDown handler in the menu button itself. Here is an example I used with my student the other day. They were supposed to make an application where the user should choose a starting point and an ending point for a journey, from a list of places along the route. This is a situation where you would like to filter out the starting point from the possible choices as ending point, and it is a good example of what you want to achieve. Here is a script in the menuPick handler in the first menu, that sets the options for the second menu: on menuPick pItemName put the text of me into tText repeat with i = 1 to the number of lines of tText if pItemName = line i of tText then delete line i of tText exit repeat end if end repeat set text of button "No 2" to tText show button "No 2" end menuPick This script could also be put in a mouseDown handler in the button called “No 2” with som alterations: on mouseDown put the text of button “No 1" into tText put the label of button “No 1” into tStart repeat with i = 1 to the number of lines of tText if tStart = line i of tText then delete line i of tText exit repeat end if end repeat set text of button "No 2" to tText show button "No 2" end mouseDown The number of "case entries" (menuLines) for an option menu, only apply to Windows and Linux, as they will show the option menu as a combo-box. The menuLines property defines how many lines will be displayed in the drop down list of a combo-box, without the need for scrolling. The total number of items in the menu can be any number, as the user can scroll further down the list in the combo-box. Tore Nilsen > 9. feb. 2016 kl. 20.44 skrev Francis Nugent Dixon : > > Hi from Sunny Brittany (at least it was this morning !), > > After many years of using buttons in my stacks, I am > discovering the joys of using “Pull Down” menus (and > about time too !). > > I can change the script “cases” with the “set script” command, > but I also want to know how to change the value of the menu options > on the fly, for example, if I have a menu option “Show Table” > in my button, once I have shown the table, how can I modify > the menu option to show “Hide Table”, assuming that I also > set the case in the script to the new value, with new instructions. > > I thought that it was possible to modify any button/field options > on the fly, but I can’t grab the syntax of this requirement. > > I also see that the number of case entries is defined in the button > specs. Can I change this also, or do I just set a maximum value > > I know that Klaus has played with menus (seen on forums) > Maybe he has an answer ? > > -Francis > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Modifying Drop-Down Menus on the fly
Hi Francis, I’m quite a new in livecode, so I hope I’ve understand your question right. Problem: Changing dynamically the values of the options of a menu-button. Proposal: Setting the text property of a button (style and menuMode of your choice) with a list of menu items before this control is shown. The solution I’ve found is in Jeanne Devoto’s stack about menus as part of the famous „Scripting Conference” downloadable from Jaques Landman Gay’s WebSite: http://www.hyperactivesw.com/revscriptconf/scriptingconferences.html (Thank you very much to make these stacks still available to us! These Stacks are still so instructive after such al long time and they are running perfectly in LC 8!) Excerpt out of the demo of the stack number 9 „Menu” made by Jeanne Devoto: on mouseDown -- This handler executes when you click the menu, before the menu appears. repeat with x = 1 to the number of controls of group "Gemstones" -- First we scan all the checkboxes. They're all members of a group -- called "Gemstones". For each of the checkboxes, we see whether it's -- checked (whether its hilite property is true). If so, we add that -- checkbox's label - the name of its gemstone - to end of the list of menu -- items that we're going to use: if the hilite of control x of group "Gemstones" is true then put the label of control x of group "Gemstones" & return after myItems -- The "& return" puts each menu item on a separate line. end if An additional comment from me: The group ”Gemstones“ ist here a group of controls of type checkbox. In the loop of the script the labels of the highlighted boxes are gathered in a list named myItems and later the text property of a menu button is set to this list of items. Now clicking this menu button will load the actual list of checked gemstones and will present them as options of the menu button. Later on you pick up the label-property of the menu button in a „menuPick” event handler to get the users choice of the menu button. > I can change the script “cases” with the “set script” command, I’m sorry, but I can’t follow you, may be, because I’m a newbie as I said ;-) (What does the script „cases“ looks like and why and how change this script by „set script“ command?) -Beda Am 09.02.2016 um 20:44 schrieb Francis Nugent Dixon : > Hi from Sunny Brittany (at least it was this morning !), > > After many years of using buttons in my stacks, I am > discovering the joys of using “Pull Down” menus (and > about time too !). > > I can change the script “cases” with the “set script” command, > but I also want to know how to change the value of the menu options > on the fly, for example, if I have a menu option “Show Table” > in my button, once I have shown the table, how can I modify > the menu option to show “Hide Table”, assuming that I also > set the case in the script to the new value, with new instructions. > > I thought that it was possible to modify any button/field options > on the fly, but I can’t grab the syntax of this requirement. > > I also see that the number of case entries is defined in the button > specs. Can I change this also, or do I just set a maximum value > > I know that Klaus has played with menus (seen on forums) > Maybe he has an answer ? > > -Francis > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Modifying Drop-Down Menus on the fly
In the button script: on mouseDown -- put your list of choices into the button end mouseDown on menuPick pPicked -- act on the selected option end menuPick That should work! Phil Davis On 2/9/16 11:44 AM, Francis Nugent Dixon wrote: Hi from Sunny Brittany (at least it was this morning !), After many years of using buttons in my stacks, I am discovering the joys of using “Pull Down” menus (and about time too !). I can change the script “cases” with the “set script” command, but I also want to know how to change the value of the menu options on the fly, for example, if I have a menu option “Show Table” in my button, once I have shown the table, how can I modify the menu option to show “Hide Table”, assuming that I also set the case in the script to the new value, with new instructions. I thought that it was possible to modify any button/field options on the fly, but I can’t grab the syntax of this requirement. I also see that the number of case entries is defined in the button specs. Can I change this also, or do I just set a maximum value I know that Klaus has played with menus (seen on forums) Maybe he has an answer ? -Francis ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode -- Phil Davis ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Modifying Drop-Down Menus on the fly
Set the text of the button to the list of menu items. Also look in the dictionary under menu for more drop down menu features. eric ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Modifying Drop-Down Menus on the fly
Hi from Sunny Brittany (at least it was this morning !), After many years of using buttons in my stacks, I am discovering the joys of using “Pull Down” menus (and about time too !). I can change the script “cases” with the “set script” command, but I also want to know how to change the value of the menu options on the fly, for example, if I have a menu option “Show Table” in my button, once I have shown the table, how can I modify the menu option to show “Hide Table”, assuming that I also set the case in the script to the new value, with new instructions. I thought that it was possible to modify any button/field options on the fly, but I can’t grab the syntax of this requirement. I also see that the number of case entries is defined in the button specs. Can I change this also, or do I just set a maximum value I know that Klaus has played with menus (seen on forums) Maybe he has an answer ? -Francis ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode