Update Mac menubar
Shari
gypsyware at earthlink.net
Wed Sep 11 20:08:01 EDT 2002
You guys were so helpful! Jacque is the official winner of the
Dreamboat Challenge, and still hasn't claimed her free registration
:-)
The final solution to allow me to hide/show menu buttons and have the
Mac menubar update is this:
For people searching the archives with this question, this is a
menuGroup in the background, that appears on all cards. What I
wanted to do was to hide/show menu buttons when changing cards.
on preOpenCard
show btn "Options"
hide btn "Strategies"
hide btn "High Scores"
end preOpenCard
This did not work. The Mac menubar did not update from a script, no
matter what I tried. I finally settled on the following solution,
which I am quite happy with:
The real buttons are hidden, and are as follows:
named "Options1" and labeled "Options"
named "Strategies1" and labeled "Strategies"
named "Empty1" with no label # for when there is no button to show
There are other buttons, but they do not change from card to card.
There is a changeling button, with the id of 3636, that is visible.
The scripts are as follows:
in each card:
# put the name of the button you want to show into gButton
on preOpenCard
global gButton
put "Options1" into gButton # use the name of the real hidden
button that you want to show
updateMenus
end preOpenCard
# use closeCard only for the buttons that can be changed by the user
# for example, if a menu item can be checked or unchecked, and you
want this to be remembered
# the closeCard handler saves the user changes to the hidden real button
on closeCard
global gButton
put btn id 3636 into gButton
end closeCard
# in the script of each button, if a menu item is changed by the user
and i want that info
# saved, there is a saveData handler that gets called
# for example:
case "Sound Effects"
global soundIsOn
if char 2 of line 18 of btn "Options" is "c" then
put "n" into char 2 of line 18 of btn "Options" # uncheck
put "no" into soundIsOn
else
put "c" into char 2 of line 18 of btn "Options" #check
put empty into soundIsOn
end if
saveData # saves user changes to an external stack, since
standalones cannot save to themselves
break
in the stack script:
on updateMenus
global gButton
set the name of btn id 3636 to the label of btn gButton
put btn gButton into btn id 3636
set the script of btn id 3636 to the script of btn gButton
# copy the custom properties into the changeling button
get the customKeys of btn gButton
set the customKeys of btn id 3636 to it
put it into tit
repeat for each line x in tit
get the x of btn gButton
set the x of btn id 3636 to it
end repeat
end updateMenus
--
--Shareware Games for the Mac--
http://www.gypsyware.com
More information about the metacard
mailing list