#!/bin/sh # MetaCard 2.4 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@" Managing Menus 2"/* Menu Stack By Eric Chatonet 3/3/05 http://www.sosmartsoftware.com/ */ on preOpenStack if the short name of me <> the short name of this stack then exit preOpenStack set the showBorder of btn "PullDown Menu" to the platform = "MacOS" set the style of this stack to modeless set the loc of this stack to the screenLoc end preOpenStack ------------------------------------ on commandKeyDown pKey local tStackName ----- put "You press Command/Control" && toUpper(pKey) into fld "Result" -- for demo purpose ----- switch pKey case "a" put "revApplicationOverview" into tStackName break case "b" put "revDBQuerySetup" into tStackName break case "c" put "revMenuManager" into tStackName break case "d" put "Message Box" into tStackName break case "e" put "revTools" into tStackName break default pass commandKeyDown end switch ----- if tStackName is among the lines of the openStacks then GoStack tStackName -- -- we could have put this line directly into each case of the switch structure -- using a variable minimizes typing effort and makes the handler clearer :-) -- see GoStack handler below end commandKeyDown ------------------------------------ on GoStack pStack -- this handler is called by the menuPick handler placed in the menu button script -- and by the commandKeyDown handler over there -- pStack parameter is the short name of the stack the user chose go stack pStack end GoStack Bulding Menus on the Fly U Lucida Grande U Lucida Grande W Lucida Grande W Lucida Grande W Courier U Courier U Courier U Courier AU Lucida Grande Pulldown Menu cREVGeneral scriptChecksum µ!D7 debugObjects breakPoints handlerList #preOpenStack commandKeyDown GoStackscriptSelection char 346 to 345 bookmarks tempScript prevHandler commandKeyDownscript
/*
Menu Stack
By Eric Chatonet
3/3/05
http://www.sosmartsoftware.com/
*/
on preOpenStack
if the short name of me <> the short name of this stack then exit preOpenStack
set the showBorder of btn "PullDown Menu" to the platform = "MacOS"
set the style of this stack to modeless
set the loc of this stack to the screenLoc
end preOpenStack
------------------------------------
on commandKeyDown pKey
local tStackName
-----
put "You press Command/Control" && toUpper(pKey) into fld "Result" -- for demo purpose
-----
switch pKey
case "a"
put "revApplicationOverview" into tStackName
break
case "b"
put "revDBQuerySetup" into tStackName
break
case "c"
put "revMenuManager" into tStackName
break
case "d"
put "Message Box" into tStackName
break
case "e"
put "revTools" into tStackName
break
default
pass commandKeyDown
end switch
-----
if tStackName is among the lines of the openStacks then GoStack tStackName --
-- we could have put this line directly into each case of the switch structure
-- using a variable minimizes typing effort and makes the handler clearer :-)
-- see GoStack handler below
end commandKeyDown
------------------------------------
on GoStack pStack
-- this handler is called by the menuPick handler placed in the menu button script
-- and by the commandKeyDown handler over there
-- pStack parameter is the short name of the stack the user chose
go stack pStack
end GoStack
@ cREVGeneral scriptChecksum ُ B~ bookmarks handlerList scriptSelection char 1 to 0prevHandler preOpenCardtempScript script @ BlackCheckmark.png PNG IHDR pHYs gAMA |Q cHRM z% u0 ` : o_F xIDATxb` 17 R@L:̤/@,0@ 1I +x%@ Lħ HW ť $@PIV dĊK8 0 6 IENDB` cREVGeneral revUniqueID 1109347801497 CheckBox i - M cREVGeneral revUniqueID 1109350058804 Pulldown Menu uon mouseDown local tMenu,tOpenStacks,tLineNum,tStack,tOpenStacksList ----- first, we get the outline stored as a custom property into the button itself: put the uMenu of me into tMenu -- this outline only contains invariant elements: see it using the property palette ----- we check the right platform: put "!c" before line lineOffset(the platform,tMenu) of tMenu -- "!c" at the beginning of a line will checkmark the corresponding menu or sub-menu item ----- we check available tools sub-menu items: put the openStacks into tOpenStacks set the itemDel to tab if "revApplicationOverview" is not among the lines of tOpenStacks then put "(" before last item of line lineOffset("Application Browser",tMenu) of tMenu if "revDBQuerySetup" is not among the lines of tOpenStacks then put "(" before last item of line lineOffset("Database Query Builder",tMenu) of tMenu if "revMenuManager" is not among the lines of tOpenStacks then put "(" before last item of line lineOffset("Menu Builder",tMenu) of tMenu if "Message Box" is not among the lines of tOpenStacks then put "(" before last item of line lineOffset("Message Box",tMenu) of tMenu if "revTools" is not among the lines of tOpenStacks then put "(" before last item of line lineOffset("Tools Palette",tMenu) of tMenu -- a parenthesis at the beginning of a line will disable the corresponding menu or sub-menu item -- note that for most of these tools, rev stack's names are not the names we are used to ;-) ----- we list all open stacks as sub menu items: repeat for each line tStack in tOpenStacks -- repeat for form is always better than repeat with i = 1 to etc. form (above all in case of numerous loops) put tab & tStack & cr after tOpenStacksList -- tab makes each stack a submenu item end repeat delete last char of tOpenStacksList -- last char is a return put return & tOpenStacksList after line lineOffset("Available Stacks",tMenu) of tMenu -- I know: "Available Stacks" is the first line of the menu but, when developing further and changing my mind... -- using lineOffset function instead of line x of tMenu lets you change the outline without any garbage :-) ----- menu is now built: set the text of me to tMenu -- here the menu stays very simple for the demo purpose -- sometimes several hundreds of lines of code can be necessary... -- when building a complex menu with sub/sub... menu items and nested lists, pay special attention to returns and tabs end mouseDown ------------------------------------- on menuPick pItem -- this handler is here for demonstrating the principles of a complete menuPick architecture -- with nested switch structures ----- set the itemDel to "|" -- switch item 1 of pItem case "Available Stacks" -- you don't know the exact contents of the sub-menu item but it does not matter -- since you know that is the short name of an open stack GoStack item 2 of pItem -- S -- item 2 of pItem is the short name of an open stack: it is passed as a parameter -- see GoStack handler in stack's script break case "Open Tools" -- menu item switch item 2 of pItem case "Application Browser" GoStack "revApplicationOverview" -- S -- item 2 of pItem is not the short name of an open stack: parameter is especially defined for each case -- see GoStack handler in stack's script break case "Database Query Builder" GoStack "revDBQuerySetup" -- S break case "Menu Builder" GoStack "revMenuManager" -- S break case "Message Box" GoStack item 2 of pItem -- S -- here we can use the sub menu item: it's the effective short stack name break case "Tools Palette" GoStack "revTools" -- S end switch break case "Platform" -- another menu item -- etc. end switch ----- put item 1 of pItem && ">" && item 2 of pItem into fld "Result" -- for demo purpose end menuPick function DisableMenuItem pItem if pItem = empty then return pItem set the itemDel to tab repeat with i = 1 to the number of items of pItem if item i of pItem <> empty then put "(" before item i of pItem exit repeat end if end repeat return pItem end DisableMenuItem f Y x uMenu Available Stacks Open Tools Application Browser/A Database Query Builder/B Menu Builder/C Message Box/D Tools Palette/E - Platform MacOS Win32 Linux - HP-9000//700 SGI IRIS IBM RS//6000 Intel SCO Intel SVR4 SPARC SPARC Solaris Available Stacks Managing Menus Message Box rev_Color Picker 1.0 rev_Backups Picker 1.1 revTools rev_Objects Picker 1.0 revVGuide revHGuide Stacks Picker 1.0 TutorialsFromS3 rev_Guides Picker 2.0 Untitled 1 Report Picker 1.0 Windows Picker 1.0 revMenubar Open Tools (Application Browser/A (Database Query Builder/B (Menu Builder/C Message Box/D Tools Palette/E - Platform !c MacOS Win32 Linux - HP-9000//700 SGI IRIS IBM RS//6000 Intel SCO Intel SVR4 SPARC SPARC Solaris cREVGeneral scriptChecksum %#=Ta7QF bookmarks revUniqueID 1109456569474handlerList "mouseDown menuPick DisableMenuItemscriptSelection char 996 to 1091prevHandler mouseDowntempScript script (on mouseDown
local tMenu,tOpenStacks,tLineNum,tStack,tOpenStacksList
----- first, we get the outline stored as a custom property into the button itself:
put the uMenu of me into tMenu
-- this outline only contains invariant elements: see it using the property palette
----- we check the right platform:
put "!c" before line lineOffset(the platform,tMenu) of tMenu
-- "!c" at the beginning of a line will checkmark the corresponding menu or sub-menu item
----- we check available tools sub-menu items:
put the openStacks into tOpenStacks
set the itemDel to tab
if "revApplicationOverview" is not among the lines of tOpenStacks then put "(" before last item of line lineOffset("Application Browser",tMenu) of tMenu
if "revDBQuerySetup" is not among the lines of tOpenStacks then put "(" before last item of line lineOffset("Database Query Builder",tMenu) of tMenu
if "revMenuManager" is not among the lines of tOpenStacks then put "(" before last item of line lineOffset("Menu Builder",tMenu) of tMenu
if "Message Box" is not among the lines of tOpenStacks then put "(" before last item of line lineOffset("Message Box",tMenu) of tMenu
if "revTools" is not among the lines of tOpenStacks then put "(" before last item of line lineOffset("Tools Palette",tMenu) of tMenu
-- a parenthesis at the beginning of a line will disable the corresponding menu or sub-menu item
-- note that for most of these tools, rev stack's names are not the names we are used to ;-)
----- we list all open stacks as sub menu items:
repeat for each line tStack in tOpenStacks
-- repeat for form is always better than repeat with i = 1 to etc. form (above all in case of numerous loops)
put tab & tStack & cr after tOpenStacksList
-- tab makes each stack a submenu item
end repeat
delete last char of tOpenStacksList -- last char is a return
put return & tOpenStacksList after line lineOffset("Available Stacks",tMenu) of tMenu
-- I know: "Available Stacks" is the first line of the menu but, when developing further and changing my mind...
-- using lineOffset function instead of line x of tMenu lets you change the outline without any garbage :-)
----- menu is now built:
set the text of me to tMenu
-- here the menu stays very simple for the demo purpose
-- sometimes several hundreds of lines of code can be necessary...
-- when building a complex menu with sub/sub... menu items and nested lists, pay special attention to returns and tabs
end mouseDown
-------------------------------------
on menuPick pItem
-- this handler is here for demonstrating the principles of a complete menuPick architecture
-- with nested switch structures
-----
set the itemDel to "|"
--
switch item 1 of pItem
case "Available Stacks"
-- you don't know the exact contents of the sub-menu item but it does not matter
-- since you know that is the short name of an open stack
GoStack item 2 of pItem -- S
-- item 2 of pItem is the short name of an open stack: it is passed as a parameter
-- see GoStack handler in stack's script
break
case "Open Tools" -- menu item
switch item 2 of pItem
case "Application Browser"
GoStack "revApplicationOverview" -- S
-- item 2 of pItem is not the short name of an open stack: parameter is especially defined for each case
-- see GoStack handler in stack's script
break
case "Database Query Builder"
GoStack "revDBQuerySetup" -- S
break
case "Menu Builder"
GoStack "revMenuManager" -- S
break
case "Message Box"
GoStack item 2 of pItem -- S
-- here we can use the sub menu item: it's the effective short stack name
break
case "Tools Palette"
GoStack "revTools" -- S
end switch
break
case "Platform" -- another menu item
-- etc.
end switch
-----
put item 1 of pItem && ">" && item 2 of pItem into fld "Result" -- for demo purpose
end menuPick
function DisableMenuItem pItem
if pItem = empty then return pItem
set the itemDel to tab
repeat with i = 1 to the number of items of pItem
if item i of pItem <> empty then
put "(" before item i of pItem
exit repeat
end if
end repeat
return pItem
end DisableMenuItem
Label Field &