Hi Rodney,

andu wrote:
> 
> >OK everyone, here's a basic question.
> >
> >What's the best (simplest and most elegant) way of doing a graphical
> >button roll over in Metacard?
> >
> >Button may be a combination of button and image objects, as long as
> >they appear to the user as a single object/button.
> >
> >Button states required:
> >1  Nothing/MouseUp - show default/up state image
> >2  Mousewithin - show rollover state image
> >3  MouseDown - show down state image
> >
> >Notes:
> >- If the user clicks down on the "button" (state 2) and drags their
> >mouse outside of the object the state must switch to up (1), if while
> >still holding the mouse down they drag the mouse back into the object
> >the state must switch back to down (3).  The only way I can see to do
> >this is to continually check whether the mouse is within the rect of
> >the object.

Here's one way (using an external file for each button state):

on mouseEnter
  set the filename of the target to "rollover.jpg"
end mouseEnter

on mouseLeave
  set the filename of the target to "normal.jpg"
end mouseLeave

on mouseDown
  set the filename of the target to "down.jpg"
  send "checkMouseLoc" to the target in 20 milliseconds
end mouseDown

on mouseUp
  cancel item 1 of the pendingMessages
  if the mouseLoc is within the rect of the target
  then set the filename of the target to "rollover.jpg"
  else set the filename of the target to "normal.jpg"
end mouseUp

on mouseRelease
  set the filename of the target to "normal.jpg"
end mouseRelease

on checkMouseLoc
  -- checked only while the mouse is down
  if the mouseLoc is within the rect of the target
  then set the filename of the target to "down.jpg"
  else set the filename of the target to "normal.jpg"

  send "checkMouseLoc" to the target in 20 milliseconds
end checkMouseLoc


Just having some good clean fun...
Phil

> >
> >The best way I have found to achieve this sort of roll-over is to
> >create a MC button object and then create the various state images
> >(on top of each other) in layers below it.  The button captures the
> >mouse events and shows/hides the images.
> >
> >Related question: does MC have a syntax to put an image into another
> >image (along lines of OMO's "put cd image 1 into cd  image id 5")
> 
> set the fileName of image 2 to the fileName of image 1
> 
> >
> >
> >--
> >
> >************************************************************
> >Rodney Tamblyn
> 
> Regards, Andu
> 
> This is the MetaCard mailing list.
> Archives: http://www.mail-archive.com/metacard%40lists.best.com/
> Info: http://www.xworlds.com/metacard/mailinglist.htm

-- 
Phil Davis
------------------
[EMAIL PROTECTED]

This is the MetaCard mailing list.
Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm

Reply via email to