Menubar on Windows???
Ken Ray
kray at sonsothunder.com
Tue Dec 11 12:11:33 EST 2007
On Tue, 11 Dec 2007 15:17:27 +0000, Dave wrote:
> This is what I don't understand. How to I set the "menu group" on
> Windows? I can (and have set it and it works ok on Mac). I have a
> Menubar group in a stack called "MenuBar" how can I use this menubar
> group as the menu bar for the current stack under Windows?
Richard provided one way to make this happen (the floating palette
that's only a menu while all your other stack windows don't have a menu
bar at all). But as he pointed out, this is non-standard. So to make
the same set of menus appear in all of your open stack windows, you
will need to copy the group that contains the buttons that act as the
menus (the "menu group") to each stack - there isn't a way of setting a
"defaultMenuBar" as there is in OS X. And since they will need to be
copied, it is strongly recommended to *NOT* put the code that deals
with the menu items inside the buttons that make up the menubar itself,
as if you need to make a change to the code, you'd have to copy and
paste it between all the same buttons in each of the open stacks... I
tend to use (as do many others here on the list) a convention where the
buttons in the menu group have no script at all, and the menu group has
a single "menupick" handler that strips away the crud from the menu
item name, collapses it into a single word and calls a centralized set
of menu handlers (either in the main stack script or in a library or
backscript). Something like this:
on menuPick pMenuItemName
put the short name of the target into tMenuName
put " ,...,!c,!n,!r,!u" into tSpecialChars
repeat for each item tItem in tSpecialChars
replace tItem with "" in pMenuItemName
end repeat
do (tMenuName & "_" & pMenuItemName)
end menuPick
So if you selected "Page Setup..." from the "File" menu, the menuPick
handler above would "do" the command "File_PageSetup", which you could
trap in the mainstack script/library/backscript:
on File_PageSetup
-- your code here
end File_PageSetup
Other people I know do something similar but like one large "DoMenu"
handler, so they'll change the last line of the 'menuPick' handler code
above to:
do ("DoMenu" && tMenuName & "," & pMenuItemName)
and have a DoMenu handler like this:
on DoMenu pMenu,pItem
switch pMenu
case "File"
switch pItem
case "New"
-- code here
break
case "PageSetup"
-- code here
break
-- etc. for all File menu items
end switch
break
case "Edit"
-- same switch structure here for Edit menu items
break
end switch
end DoMenu
Anyway, hope this helps get the mental juices flowing...
;-)
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