Livecode Wiki
Advertisement

A message sent when the user release the mouse button after a click. If there is a message handler by the same name in the message path, then it will be executed.

Message[]

Syntax:

mouseUp mousebutton

The parameter <mousebutton> is 1 if the mouse button is on a Mac OS systems. If it is 2, then it is the left button on a Windows system or a Unix system, or a Control-click on Mac OS systems. If it is a 3, it is the middle mouse button on a Unix systems.

The mouseUp message is sent to the button card control that was clicked. The mouseUp message is sent only when the Browse tool is being used. If an unlocked field is clicked with mouse button 1 or 2, no mouseUp message is sent.

If the mouse has moved outside the control that was originally clicked before the user releases the mouse button, the mouseRelease message is sent instead. If the click is the second click of a double click, the mouseDoubleUp message is sent instead.

Message Handler[]

Examples:

on mouseUp
 answer "You clicked" & (the name of the target)
end mouseUp
on mouseUp mousebutton
 answer "You clicked button " & mousebutton
end mouseUp

If the user clicks several times in rapid succession (for example, if the user clicks an "Increase" button that increases a number by 1), some of the clicks may send a mouseDoubleUp message instead of mouseUp. If your message handler only handles the mouseUp message, these accidental double clicks will be lost. One way to prevent this is to install a handler in an object that's further along the message path, to re-send double clicks:

on mouseDoubleUp
  if "on mouseUp" is in the script of the target and "on mouseDoubleUp" is not in the script of the target then 
     send "mouseUp" to the target
  end if
end mouseDoubleUp

If the user double-clicks an object whose script contains a mouseUp handler but no mouseDoubleUp, the above handler will automatically send a mouseUp to the object so the second click can be handled normally (instead of as a double-click).

If the user clicks a transparent pixel in an image, the mouseUp message is sent to the object behind the image, not to the image.

Advertisement