Setting MenuButton on openCard

Ken Ray kray at sonsothunder.com
Tue Aug 7 12:10:45 EDT 2007


On Tue, 7 Aug 2007 11:58:07 -0400, Mikey wrote:

> on openCard
>    set the menuHistory of button "menu" to the number of this card
> end openCard
> 
> However, when I either send openCard or navigate, nothing happens
> visually, i.e. the option menu doesn't change its label, UNTIL I
> manually change it once by clicking on it.  Then it works as expected.
> 
> BEFORE manually changing it, the menuHistory and the label are what I
> would expect them to be, but the display is improper.

The problem is that you are just changing the menuHistory, which 
identifies the index number of the item that should be highlighted when 
the men pops up. You actually need to change the label too in order to 
get the text you want, especially if the menuHistory is already 
correct. And if you have code that would be triggered in the menu 
button that you don't want to trigger on openCard, here's how I do it:

on openCard
  set the label of button "menu" to (the short name of this card)
  lock messages
  set the menuHistory of button "menu" to the number of this card
  unlock messages
end openCard

Oh, and you should probably do it on "preOpenCard" instead of 
"openCard", otherwise the user will see the menu shift (unless that's 
what you want to show).

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