Futurebasic/Language/Reference/on mouse

From Wikibooks, open books for an open world
Jump to navigation Jump to search

ON MOUSE[edit | edit source]

Statement[edit | edit source]

(+) Appearance (+) Standard Console

Syntax[edit | edit source]

ON MOUSE {FN userFunction|GOSUB{lineNumber|"stmtLabel"}}

Description[edit | edit source]

This statement designates a particular function or subroutine as a mouse-event handling routine. A mouse-event handling routine is called in response to a mouseclick which occurs inside the content region of the currently active window (but not inside any buttons, scrollbars, edit fields nor picture fields).

After such a mouseclick occurs, FB does not call your designated routine immediately. Instead, your program continues executing until a HANDLEEVENTS statement is reached. At that time, HANDLEEVENTS will call your designated routine once for each mouseclick event that occurred; your designated routine should examine the MOUSE <event> functions to get information about the event.

If you use the ON MOUSE FN userFunction syntax, then userFunction must refer to a function which was defined or prototyped at an earlier location in the source code. Your mouse-event handling function should not take any parameters, nor return a result.

If your program does not use HANDLEEVENTS, you can use the MOUSE(_down), MOUSE(_lastMVert), MOUSE(_lastMHorz) and many other position functions (outlined in the FB Mouse Group of the constants document) to track mouse activity.

See Also[edit | edit source]

MOUSE <event> MOUSE(_down); MOUSE <position> HANDLEEVENTS