# Futurebasic/Language/Reference/mouse event
## MOUSE <event>
### Syntax

clickType = MOUSE(0) locationInfo = MOUSE(locationType)

### Revised

February, 2002 (Release 6)

### Description

If you have designated a mouse-event handling routine using the ON MOUSE statement, then the MOUSE <event> functions return information about a mouse click event. Your mouse-event handling routine should check the MOUSE(0) function, and possibly the MOUSE(locationType) functions, each time your routine is called.
The MOUSE <event> functions will not report a mouse click that occurs inside an active control (such as a button or scrollbar), or in an edit field or picture field, or anywhere outside the active window's content region. Such mouse clicks are handled by other routines, such as your dialog-event handling routine (see the <a href="dialog%20function.html">DIALOG</a> function), or your menu-event handling routine (see the <a href="menu%20function.html">MENU</a> function).
MOUSE(0) function The MOUSE(0) function indicates whether a single, double or triple-click occurred. It will usually return one of the following values:
Image was here
In rare cases, the user may have time to both click the mouse and release it before your program detects the click. This can happen, for example, if your program runs a long time between successive calls to HANDLEEVENTS. In that case, MOUSE(0) may return one of the following values:
Image was here
If you just want to detect the click, and you don't care whether the user released the mouse button before your mouse-event handling routine was called, then your routine can just check ABS(MOUSE(0)), which will always return 1, 2 or 3.
MOUSE(locationType) functions To detect where the mouse pointer was at the instant it was clicked, call the MOUSE(_lastMHorz) and MOUSE(_lastMVert) functions within your mouse-event handling routine. The values returned by MOUSE(_lastMHorz) and MOUSE(_lastMVert) are usually the same as those returned by MOUSE(_horz) and MOUSE(_vert) (see the <a href="mouse%20position.html">MOUSE <position></a> functions), but they may be different, especially if the mouse is being moved quickly.
If MOUSE(0) returns a positive value (indicating that the mouse was both clicked and released before your mouse-event handling routine was called), then you may also be interested in the values returned by MOUSE(_releaseHorz)ÊÊand MOUSE(_releaseVert). These values tell you where the mouse pointer was at the instant the mouse button was released. If MOUSE(0) returned a negative value, then MOUSE(_releaseHorz) and MOUSE(releaseVert) are meaningless.
MOUSE Window (Appearance Manager) A new selector helps your program determine where the mouse is located:
wndNum = MOUSE(_mouseWindow)
...will return the FB window reference number of the window over which the mouse is positioned. The window does not need to be active when this is used.
Click Sequencing FB reports a mouseclick event as soon as it can after the mouse button has been pressed down. If the user executes a double-click, FB interprets it first as a single-click event and then (once the second click happens) as a double-click event. Both "events" will be reported to your mouse-event handling routine. Similarly, if the user executes a triple-click, FB will first report a single-click event, then a double-click event, and finally a triple-click event.
You should take this into account when writing your mouse-event handling routine. The example program "DoubleClick.BAS" handles single-clicks and double-clicks; like most well-designed programs, its interface is designed so that the effects of a single-click are included in the effects of a double-click.
Waiting for the Mouse Up In most cases, FB will call your mouse-event handling routine while the mouse button is still being held down. But in some situations, your routine may need to track the mouse's motion until the button is released. You can use the Toolbox function FN STILLDOWN to determine when the user releases the mouse button. See the example program, "StillDown.BAS".
Example: Image was here CD Example: DoubleClick.BAS Image was here CD Example: StillDown.BAS

### See Also

MOUSE(_down); MOUSE <position>;ON MOUSE; ANDLEEVENTS