docs
Loading...
Searching...
No Matches
MouseEvent

#include <Ultralight/dom/Event.h>

Overview

A mouse event (MouseEvent).

Get one with Event::AsMouse(). It works for mouse events (eg, click), pointer events (eg, pointerdown), and wheel (see WheelEvent).

Note
In mouse and wheel events from View::FireMouseEvent() and View::FireScrollEvent(), the modifier keys (ctrlKey() and the rest) are the ones held in the last KeyEvent you passed to View::FireKeyEvent(), since mouse and scroll events carry no modifier state.
Inheritance diagram for MouseEvent:
Event WheelEvent

Public Member Functions

 MouseEvent (ULDOMEvent borrowed)
 Wrap an event handle from the C API (Event::AsMouse() is the usual way to get one).
double clientX () const
 Get the pointer's x-position in the viewport, in CSS pixels (clientX).
double clientY () const
 Get the pointer's y-position in the viewport, in CSS pixels (clientY).
double pageX () const
 Get the pointer's x-position in the page, in CSS pixels (pageX).
double pageY () const
 Get the pointer's y-position in the page, in CSS pixels (pageY).
double screenX () const
 Get the pointer's x-position relative to the View (screenX).
double screenY () const
 Get the pointer's y-position relative to the View (screenY).
int button () const
 Get the button that caused the event (button).
unsigned buttons () const
 Get the buttons held down during the event (buttons).
bool ctrlKey () const
 Whether or not the Control key was held down (ctrlKey).
bool shiftKey () const
 Whether or not the Shift key was held down (shiftKey).
bool altKey () const
 Whether or not the Alt key was held down (altKey).
bool metaKey () const
 Whether or not the Meta key was held down (metaKey).
Element relatedTarget () const
 Get the other element of a mouse transition (relatedTarget).
Public Member Functions inherited from Event
 Event (ULDOMEvent borrowed)
 Wrap an event handle from the C API.
 Event (const Event &)=delete
Event & operator= (const Event &)=delete
std::string type () const
 Get the event's type (type).
unsigned eventPhase () const
 Get the current dispatch phase (eventPhase).
bool bubbles () const
 Whether or not the event bubbles up the tree (bubbles).
bool cancelable () const
 Whether or not preventDefault() can cancel the event (cancelable).
bool isTrusted () const
 Whether or not the event came from user input or the library (isTrusted).
double timeStamp () const
 Get the time the event was created (timeStamp).
bool defaultPrevented () const
 Whether or not the event was canceled (defaultPrevented).
void preventDefault () const
 Cancel the event's default action (preventDefault).
void stopPropagation () const
 Stop the event from reaching other targets (stopPropagation).
void stopImmediatePropagation () const
 Stop the event from reaching any other listener (stopImmediatePropagation).
Element target () const
 Get the element the event was dispatched to (target).
Node targetNode () const
 Get the node the event was dispatched to (target).
Element currentTarget () const
 Get the element whose listener is running (currentTarget).
MouseEvent AsMouse () const
 View this event as a MouseEvent.
WheelEvent AsWheel () const
 View this event as a WheelEvent.
KeyboardEvent AsKeyboard () const
 View this event as a KeyboardEvent.
FocusEvent AsFocus () const
 View this event as a FocusEvent.
InputEvent AsInput () const
 View this event as an InputEvent.
SubmitEvent AsSubmit () const
 View this event as a SubmitEvent.
CustomEvent AsCustom () const
 View this event as a CustomEvent.
ULDOMEvent raw () const
 Get the C handle, for passing to the <Ultralight/CAPI/CAPI_DOMEvent.h> functions.

Constructor & Destructor Documentation

◆ MouseEvent()

MouseEvent ( ULDOMEvent borrowed)
inlineexplicit

Wrap an event handle from the C API (Event::AsMouse() is the usual way to get one).

Parameters
borrowedThe event handle passed to a C listener callback.

Member Function Documentation

◆ altKey()

bool altKey ( ) const
inline

Whether or not the Alt key was held down (altKey).

◆ button()

int button ( ) const
inline

Get the button that caused the event (button).

Returns
Returns 0 for the left button, 1 for middle, 2 for right, 3 for back, or 4 for forward (0 for an event no button caused, like mousemove or wheel). Returns -1 for a pointermove without a button change, or for an event that isn't a mouse event.

◆ buttons()

unsigned buttons ( ) const
inline

Get the buttons held down during the event (buttons).

Returns
Returns a bitmask of 1 for left, 2 for right, 4 for middle, 8 for back, and 16 for forward (always 0 for wheel).

◆ clientX()

double clientX ( ) const
inline

Get the pointer's x-position in the viewport, in CSS pixels (clientX).

Returns
Returns the position (0 for an event without a pointer position).

◆ clientY()

double clientY ( ) const
inline

Get the pointer's y-position in the viewport, in CSS pixels (clientY).

Returns
Returns the position (0 for an event without a pointer position).

◆ ctrlKey()

bool ctrlKey ( ) const
inline

Whether or not the Control key was held down (ctrlKey).

◆ metaKey()

bool metaKey ( ) const
inline

Whether or not the Meta key was held down (metaKey).

◆ pageX()

double pageX ( ) const
inline

Get the pointer's x-position in the page, in CSS pixels (pageX).

This is clientX() plus the page's horizontal scroll position.

Returns
Returns the position (0 for an event without a pointer position).

◆ pageY()

double pageY ( ) const
inline

Get the pointer's y-position in the page, in CSS pixels (pageY).

This is clientY() plus the page's vertical scroll position.

Returns
Returns the position (0 for an event without a pointer position).

◆ relatedTarget()

Element relatedTarget ( ) const
inline

Get the other element of a mouse transition (relatedTarget).

On mouseover and mouseenter this is the element the pointer left. On mouseout and mouseleave it's the element the pointer entered.

Returns
Returns the element (empty if there's none).

◆ screenX()

double screenX ( ) const
inline

Get the pointer's x-position relative to the View (screenX).

This is the position you passed to View::FireMouseEvent() (in the View's logical pixels), not a position on the screen.

Returns
Returns the position (0 for an event without a pointer position).

◆ screenY()

double screenY ( ) const
inline

Get the pointer's y-position relative to the View (screenY).

This is the position you passed to View::FireMouseEvent() (in the View's logical pixels), not a position on the screen.

Returns
Returns the position (0 for an event without a pointer position).

◆ shiftKey()

bool shiftKey ( ) const
inline

Whether or not the Shift key was held down (shiftKey).


The documentation for this class was generated from the following files: