Modifying Drop-Down Menus on the fly

Beda Sellung Posteo b.sellung at posteo.de
Wed Feb 10 13:58:20 EST 2016


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 <effendi at wanadoo.fr>:

> 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list