The OpenD Programming Language

MouseDownEvent

Indicates that the user has worked with the mouse over your widget. For available properties, see MouseEventBase.

More...
class MouseDownEvent : MouseEventBase {}

Members

Manifest constants

EventString
enum EventString;

Inherited Members

From MouseEventBase

clientX
int clientX;
clientY
int clientY;

The mouse event location relative to the target widget

viewportX
int viewportX;
viewportY
int viewportY;

The mouse event location relative to the window origin

button
int button;

See: MouseEvent.button

buttonLinear
int buttonLinear;

See: MouseEvent.buttonLinear

ctrlKey
bool ctrlKey;
altKey
bool altKey;
shiftKey
bool shiftKey;

Indicates the current state of the given keyboard modifier keys.

state
int state;
modifierState
alias modifierState = state

for consistent names with key event.

isMouseWheel
bool isMouseWheel()

Mouse wheel movement sends down/up/click events just like other buttons clicking. This method is to help you filter that out.

Detailed Description

Important: MouseDownEvent, MouseUpEvent, ClickEvent, and DoubleClickEvent are all sent for all mouse buttons and for wheel movement! You should check the button property in most your handlers to get correct behavior.

MouseDownEvent is sent when the user presses a mouse button. It is also sent on mouse wheel movement.

MouseUpEvent is sent when the user releases a mouse button.

MouseMoveEvent is sent when the mouse is moved. Please note you may not receive this in some cases unless a button is also pressed; the system is free to withhold them as an optimization. (In practice, arsd.simpledisplay does not request mouse motion event without a held button if it is on a remote X11 link, but does elsewhere at this time.)

ClickEvent is sent when the user clicks on the widget. It may also be sent with keyboard control, though minigui prefers to send a "triggered" event in addition to a mouse click and instead of a simulated mouse click in cases like keyboard activation of a button.

DoubleClickEvent is sent when the user clicks twice on a thing quickly, immediately after the second MouseDownEvent. The sequence is: MouseDownEvent, MouseUpEvent, ClickEvent, MouseDownEvent, DoubleClickEvent, MouseUpEvent. The second ClickEvent is NOT sent. Note that this is differnet than Javascript! They would send down,up,click,down,up,click,dblclick. Minigui does it differently because this is the way the Windows OS reports it.

MouseOverEvent is sent then the mouse first goes over a widget. Please note that this participates in event propagation of children! Use MouseEnterEvent instead if you are only interested in a specific element's whole bounding box instead of the top-most element in any particular location.

MouseOutEvent is sent when the mouse exits a target. Please note that this participates in event propagation of children! Use MouseLeaveEvent instead if you are only interested in a specific element's whole bounding box instead of the top-most element in any particular location.

MouseEnterEvent is sent when the mouse enters the bounding box of a widget.

MouseLeaveEvent is sent when the mouse leaves the bounding box of a widget.

You can construct these yourself, but generally the system will send them to you and there's little need to emit your own.

Rationale:

If you only want to do drag, mousedown/up works just fine being consistently sent.

If you want click, that event does what you expect (if the user mouse downs then moves the mouse off the widget before going up, no click event happens - a click is only down and back up on the same thing).

If you want double click and listen to that specifically, it also just works, and if you only cared about clicks, odds are the double click should do the same thing as a single click anyway - the double was prolly accidental - so only sending the event once is prolly what user intended.

Meta

History

Added May 2, 2021. Previously, it was only seen as the base Event class on event listeners. See the member EventString to see what the associated string is with these elements.