The Lingo:
(Syntax highlighting provided by David Mennenoh's way cool HTML-ingo
utility).
-- menuActivator script
global gMenuActive
property spriteNum,
mySprite
property myMem, overOn, overMem
property myGroup, myGroupActive
on beginSprite
me
mySprite = sprite(spriteNum)
myMem = mySprite.member
end
on mouseDown
me
if myGroup = "Control"
then
gMenuActive = 0
else
gMenuActive = NOT gmenuActive
end if
end
on mouseUp me
sendAllSprites(#toggleVis,myGroup)
end
on mouseEnter
me
if myGroup = "Control"
then exit
if gMenuActive then
if overOn and
myGroupActive then mySprite.member
= member(overMem)
sendAllSprites(#toggleVis,myGroup,1)
end if
updateStage
end
on activate me,
whichGroup, whichWay
if whichGroup <> myGroup
then
myGroupActive = 0
else
myGroupActive = whichWay
end if
if whichWay = 1
then
mySprite.member =
member(overMem)
else mySprite.member
= member(myMem)
end
on deactivate me
myGroupActive = 0
end
on getPropertyDescriptionList
me
if the
currentSpriteNum < 1
then exit
pList = [:]
tmp = sprite(the
currentSpriteNum).member
if member(tmp).type
= #bitmap then
memNum = member(tmp).number
+ 1
memLib = member(tmp).castLibNum
defMem = member(memNum,memLib)
else defMem = tmp
pList.addProp (#overOn,[¬
#comment:"Rollover
on?",¬
#format:#boolean,¬
#default:1])
pList.addProp (#overMem,[¬
#comment:"Rollover
member",¬
#format:#graphic,¬
#default:defMem])
pList.addProp(#myGroup,[¬
#comment:"Name
of my group of sprites",¬
#format:#string,¬
#default:""])
return pList
end
on getBehaviorDescription
me
str = " Use this behavior along
with the" &"e &"MenuBehavior"
"e &&"behavior
" &¬
"to create a menuing system. It
uses graphic members for all the menu states." &RETURN
&RETURN &¬
" Drop this behavior on the sprite
that will open the menu, ie: File" &RETURN
&RETURN &¬
" It will pop up a dialog box asking
you to turn on/off the rollover feature " &¬
"(the" &"E
&"Control" "E
&&"menu is normally off), the rollover
member to " &¬
"use, and a name for grouping the
sprites used to create this menu." &RETURN
&¬
" If rollover is on and menus have
been activated by clicking this sprite " &¬
"or another sprite with this behavior,
then it will cause the sprites in this " &¬
"group to become visible and cause
other opened menus (groups) to disappear."
return str
end
|
-- menuBehavior script
global gMenuActive
property spriteNum,
mySprite
property myMem, overOn, overMem, myDisableMem,
myDisableOverMem
property lingoOn, doLingo
property myGroup, myGroupActive, myMenuSprite
property myEnable, myStartEnable
property myTipOn, myTip, myTipSprite, myTipMem
property myLoc
on beginSprite
me
mySprite = sprite(spriteNum)
myLoc = mySprite.loc
mySprite.locV = -1000
myMem = mySprite.member
myGroupActive = 0
if myTipOn then
myTipMem = sprite(myTipSprite).member
if NOT myStartEnable then
myEnable = 0
mySprite.member =
member(myDisableMem)
else
myEnable = 1
end if
end
on mouseEnter
me
if myTipOn then
member(myTipMem).text
= myTip
if overOn then
if myEnable then
mySprite.member
= member(overMem)
else mySprite.member
= member(myDisableOverMem)
end if
updateStage
end
on mouseLeave
me
if myTipOn then
member(myTipMem).text
= EMPTY
if myEnable then
mySprite.member =
myMem
else mySprite.member
= member(myDisableMem)
end
on mouseUp me
if myEnable then
if myTipOn then
member(myTipMem).text
= EMPTY
sendAllSprites(#toggleVis,myGroup,0)
updateStage
gMenuActive = 0
if lingoOn and
myEnable then
do doLingo
end if
end if
end
on mouseUpOutside
me
if myTipOn then
member(myTipMem).text
= EMPTY
gMenuActive = 0
sendAllSprites(#toggleVis,myGroup,0)
end
on endSprite
me
sprite(spriteNum).visible
= 1
end
-- usage: sendAllSprites(#toggleVis,"groupName",[0|1])
on toggleVis me,
whichGroup, whichWay
-- I used "All" on the background
sprite
if whichGroup = "All"
then gMenuActive = 0
if whichGroup = myGroup then
if whichWay.voidP
then
myGroupActive = NOT myGroupActive
else
myGroupActive = whichWay
end if
else --
some other group - make sure I'm invisible
myGroupActive = 0
end if
if myGroupActive then
mySprite.loc = myLoc
else
mySprite.locV = -1000
end if
-- toggle the menuActivator sprite,
too. (see menuActivator behavior)
sendSprite(myMenuSprite, #activate,
myGroup, myGroupActive)
end
-- usage: sendSprite(n,#mEnable)
on mEnable me
myEnable = 1
mySprite.member = member(myMem)
end
-- usage: sendSprite(n,#mDisable)
on mDisable me
myEnable = 0
mySprite.member = member(myDisableMem)
end
on getPropertyDescriptionList
me
if the
currentspriteNum < 1
then exit
pList = [:]
defMem = sprite(the
currentSpriteNum).member
tipList = []
menuList = []
repeat with
i = 1 to the
lastChannel
theType = sprite(i).member.type
if theType = #empty
then next repeat
menuList.append(i
&&"-" &&sprite(i).member.name)
if theType = #field
then
tipList.append(i
&&"-" &&sprite(i).member.name)
end if
end repeat
defTip = tipList[1]
defMenu = menuList[1]
pList.addProp (#myMenuSprite,[¬
#comment:"Which
sprite is my menu sprite?",¬
#format:#integer,¬
#default:defMenu,¬
#range:menuList])
pList.addProp (#overOn,[¬
#comment:"Rollover
on?",¬
#format:#boolean,¬
#default:1])
pList.addProp (#overMem,[¬
#comment:"Rollover
member:",¬
#format:#bitmap,¬
#default:defMem])
pList.addProp (#myStartEnable,[¬
#comment:"Initially
enabled?",¬
#format:#boolean,¬
#default:1])
pList.addProp (#myDisableMem,[¬
#comment:"Disabled
member:",¬
#format:#bitmap,¬
#default:defMem])
pList.addProp (#myDisableOverMem,[¬
#comment:"Disabled
rollover member:",¬
#format:#bitmap,¬
#default:defMem])
pList.addProp (#myTipOn,[¬
#comment:"Use
tool tip?",¬
#format:#boolean,¬
#default:1])
pList.addProp (#myTipSprite,[¬
#comment:"Which
sprite for the tips?",¬
#format:#integer,¬
#default:defTip,¬
#range:tipList])
pList.addProp(#myTip,[¬
#comment:"Tool
tip to display:",¬
#format:#string,¬
#default:""])
pList.addProp (#lingoOn,[¬
#comment:"Use
Lingo?",¬
#format:#boolean,¬
#default:0])
pList.addProp (#doLingo,[¬
#comment:"Lingo
command:",¬
#format:#string,¬
#default:"beep"])
pList.addProp(#myGroup,[¬
#comment:"Name
of my group of sprites:",¬
#format:#string,¬
#default:""])
return pList
end
on getBehaviorDescription
me
str = " Use this behavior along
with the" &"e &"MenuActivator"
"e &&"behavior
" &¬
"to create a menuing system. It
uses graphic members for all the menu states, typically:"
&RETURN &RETURN
&¬
" Enabled" &RETURN
&" Enabled - rollover" &RETURN
&" Disabled" &RETURN
&¬
" Disabled - rollover"
&RETURN &RETURN
&¬
" Drop this behavior on all the
sprites used to create a menu, including its background sprite."
&RETURN &RETURN
&¬
" It will pop up a dialog box asking
you to identify its menu activator sprite ie:File, " &¬
"whether it has rollover states
turned on/off (all off for the background sprite), " &¬
"whether it should initially display
its" &"E &"Enabled"
&"E &"state
or not, " &¬
"and which members to use for each
state (if any). You will also be asked whether to use tool-tips "
&¬
"and, if so, which sprite should
display the text and what text to display. Next you " &¬
"can turn on/off the Lingo to execute
on mouseUp and provide the Lingo to execute (may be " &¬
"custom handler). Finally, it asks
you to supply a group name for this sprite. Provide the "
&¬
"same name for all the sprites
used in a menu. For instance, all sprites in the File menu "
&¬
"might be in a group named File;
Edit for the Edit menu, etc." &RETURN
&RETURN &¬
" The" &"E
&"Control" "E
&&"menu (the one with Move, Restore,
Minimize, etc.) " &¬
"REQUIRES the group name, Control.
This is because the control menu does not open on " &¬
"mouseOver even when other menus
have been activated."
return str
end
|