|
|
|
Change Cursor
Added on 12/12/2000
|
Changes the cursor on rollover.
Download PC Source Download Mac Source
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
-- 29 InternalCursors --------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
-- Change the cursor to another one when over a sprite.
-- 29 cursors available, a few are Mac only...
-- In D7 you could set most of them in the behavior inspector window
-- In D8 no more...(as far as I know)
--
-- november, 2000
--
-- Kurt Koenig * Belgium
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
property spriteNum, pInitCurs, pChangedCurs
on getpropertydescriptionlist me
if not the currentSpriteNum then exit
pThisSprite = sprite(the currentSpriteNum).member
memberType = pThisSprite.type
permittedType = RightMemberType(me)
if not permittedType.getPos(memberType) then
return ErrorAlert (me, #PDLError, permittedType)
end if
desclist = [:]
addprop desclist,#pChangedCurs,[#comment: "The cursor to change to when over a sprite:",¬
#format: ¬
#string, ¬
#range:¬
[¬
#Arrow, ¬
#Ibeam, ¬
#Crosshair, ¬
#Crossbar, ¬
#Hourglas, ¬
#NoCursor, ¬
#Help, ¬
#Finger, ¬
#Hand, ¬
#ClosedHand, ¬
#NoDropHand, ¬
#CopyClosedHand, ¬
#Pencil, ¬
#Eraser, ¬
#Select, ¬
#Bucket, ¬
#Lasso, ¬
#Dropper, ¬
#AirBrush, ¬
#ZoomIn, ¬
#ZoomOut, ¬
#VerticalSize, ¬
#HorizonalSize, ¬
#DiagonalSize, ¬
#WhiteArrowMac, ¬
#BlackArrowOutlinedWin, ¬
#Magnify, ¬
#WaitMouse1Mac, ¬
#Waitmouse2Mac¬
],¬
#default: ¬
#Arrow¬
]
addprop desclist,#pInitCurs,[#comment: "Back to original after leaving the sprite?:",¬
#format: ¬
#boolean, ¬
#default:¬
TRUE¬
]
return desclist
end
on getBehaviorDescription me
return "¬
ChangeCursor"&RETURN&"¬
This behavior changes the cursor"&RETURN&"¬
when the mousepointer is over a "&RETURN&"¬
sprite. You can use 29 different cursors "&RETURN&"¬
KK * Belgium"
end getBehaviorDescription
on Initialize me
TheSprite = sprite(me.spriteNum)
pThisSprite = TheSprite.member
memberType = pThisSprite.type
if not RightMemberType(me).getPos(memberType) then
ErrorAlert (me, #WrongMemberType, memberType)
end if
end Initialize
-- Return the type, so an alertmessage can be displayed if the membertype is invalid.
on RightMemberType me
return [#button, #bitmap, #shape, #vectorshape, #field, #text]
end RightMemberType
-- Store the initial cursor
on beginSprite me
Initialize me
end
-- Based on James Newton's error handling code
on ErrorAlert me, theError, data
case theError of
#PDLError:
alert "¬
Error: This behavior works only with the following member types:"&RETURN&¬
RightMemberType(me)&RETURN&RETURN&"¬
Hit OK and then delete this behavior from the sprite. See the Help¬
system for details on deleting behaviors. KK"
if the optionDown then
return [ #PDLError:[ #comment: "ERROR: Wrong member type. Click 'Cancel'.", ¬
#format: #string, #range: [""], #default: ""]]
end if
otherwise
behaviorName = string (me)
delete word 1 of behaviorName
delete the last word of behaviorName
delete the last word of behaviorName
case data.ilk of
#void: data = ""
#symbol: data = "#"&data
end case
case theError of
#WrongMemberType:
alert "BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&RETURN&"¬
Behavior "&behaviorName&" only functions with the following member types: "&¬
RightMemberType()&RETURN&RETURN&¬
"Current type = "&data
halt
end case
end case
end ErrorAlert
-- Change the cursor when the mousepointer is over the sprite
on mousewithin me
case pChangedCurs of
#Arrow :
Cursor -1
#Ibeam :
Cursor 1
#Crosshair :
Cursor 2
#Crossbar :
Cursor 3
#Hourglas :
Cursor 4
#NoCursor :
Cursor 200
#Help :
Cursor 254
#Finger:
Cursor 280
#Hand :
Cursor 260
#ClosedHand :
Cursor 290
#NoDropHand :
Cursor 291
#CopyClosedHand :
Cursor 292
#Pencil :
Cursor 256
#Eraser :
Cursor 257
#Select :
Cursor 258
#Bucket :
Cursor 259
#Lasso :
Cursor 272
#Dropper :
Cursor 281
#AirBrush :
Cursor 301
#ZoomIn :
Cursor 302
#ZoomOut :
Cursor 303
#VerticalSize :
Cursor 284
#HorizonalSize :
Cursor 285
#DiagonalSize :
Cursor 286
#WhiteArrowMac :
Cursor 293
#BlackArrowOutlinedWin :
Cursor 293
#Magnify :
Cursor 304
#WaitMouse1Mac :
Cursor 282
#Waitmouse2Mac :
Cursor 283
end case
end
-- Restore back to original cursor if the checkbox in the parameterwindow is marked.
on mouseleave me
if pInitCurs then
Cursor -1
end if
end
|
|