Selecting Menu Item in Option Menu

Steven Axtell saxtell at neb.rr.com
Wed Jan 28 18:33:38 EST 2009


Thanks Ken.  That was good information.

Steve



> One thing I'd add to that - if you set the label, when you go to use the
> menu again, the item that's highlighted will *not* be what you set the 
> label
> to, but what the current menuHistory property of the button is set to.
>
> For example, if you drag out an option button onto a clean stack in Rev, 
> it
> comes with three pre-created menu items: "Choice 1", "Choice 2", and 
> "Choice
> 3", with the label reading "Choice 1" and when you click the button, the
> "Choice 1" menu item is the one that is highlighted.
>
> If you do:
>
>  set the label of btn 1 to "Choice 2"
>
> You'll see the button read "Choice 2", but when you click on it, "Choice 
> 1"
> will still be the highlighted choice (since the menuHistory of the button 
> is
> still "1").
>
> Personally, I've found it always better to lock messages and set the
> menuHistory, but it would be great if there was a better/easier way to do
> this, especially since 90% of the time I know the name I want on the 
> button,
> not the number, and I end up doing something like this:
>
> lock messages
> set the menuHistory of btn 1 to lineOffset("Choice 2",the text of btn 1)
> unlock messages
>
> and of course if for some reason if the name isn't found, it sets it to 
> the
> first item in the list, which may not be what I want, so I would have to 
> do:
>
> lock messages
> put lineOffset("Choice 2",the text of btn 1) into tNum
> if tNum <> 0 then
>  set the menuHistory of btn 1 to tNum
> end if
> unlock messages
>
> Personally, I'd love to be able to have syntax like:
>
>  set the menuChoice of <buttonObj> to <menuItemString>
>
> that would act like "set the menuHistory", but take the name of the menu
> item as an argument, and NOT trigger menuPick. Then return in "the result" 
> a
> non-empty value if for some reason the menu item you named doesn't exist.
> Like:
>
> set the menuChoice of btn 1 to "Choice 2"
> if the result is not empty then
>  -- "Choice 2" doesn't exist and I can do something about it
> end if
>
> (sigh)
>
> :-)
>
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/





More information about the Use-livecode mailing list