docs
Loading...
Searching...
No Matches
MouseEvent.h
Go to the documentation of this file.
1///
2/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3/// A license is required for commercial use. https://ultralig.ht
4///
5#pragma once
7
8namespace ultralight {
9
10///
11/// Mouse event representing a change in mouse state.
12///
13/// \parblock
14/// @note Coordinates are logical pixels: the View's device scale is not applied to them, so
15/// they run over View::width() and View::height() divided by View::device_scale().
16/// Convert from your window's device pixels before firing the event.
17/// \endparblock
18///
19/// \parblock
20/// @note Modifier keys reported to the page (eg, `shiftKey`) come from the last KeyEvent fired
21/// on the View, so you should forward modifier key presses and releases as key events.
22/// \endparblock
23///
24/// @see View::FireMouseEvent()
25///
27public:
28 ///
29 /// The various MouseEvent types.
30 ///
31 enum Type {
32 ///
33 /// Mouse moved type
34 ///
36
37 ///
38 /// Mouse button pressed type
39 ///
41
42 ///
43 /// Mouse button released type
44 ///
46 };
47
48 ///
49 /// The various mouse button types.
50 ///
51 enum Button {
55
56 ///
57 /// The right button. A right-button click also fires `contextmenu` on the page (after the
58 /// release on Windows, after the press elsewhere); the library shows no menu of its own.
59 ///
61
62 ///
63 /// The first side button ("back"), eg, X1 on Windows. Reaches the page as
64 /// `MouseEvent.button` 3; the library performs no history navigation of its own.
65 ///
67
68 ///
69 /// The second side button ("forward"), eg, X2 on Windows. Reaches the page as
70 /// `MouseEvent.button` 4; the library performs no history navigation of its own.
71 ///
73 };
74
75 ///
76 /// The type of this MouseEvent
77 ///
79
80 ///
81 /// The current x-position of the mouse, in logical pixels relative to the View.
82 ///
83 int x;
84
85 ///
86 /// The current y-position of the mouse, in logical pixels relative to the View.
87 ///
88 int y;
89
90 ///
91 /// The mouse button that was pressed/released, if any.
92 ///
94};
95
96} // namespace ultralight
Mouse event representing a change in mouse state.
Definition MouseEvent.h:26
Button
The various mouse button types.
Definition MouseEvent.h:51
@ kButton_Forward
The second side button ("forward"), eg, X2 on Windows.
Definition MouseEvent.h:72
@ kButton_None
Definition MouseEvent.h:52
@ kButton_Back
The first side button ("back"), eg, X1 on Windows.
Definition MouseEvent.h:66
@ kButton_Middle
Definition MouseEvent.h:54
@ kButton_Left
Definition MouseEvent.h:53
@ kButton_Right
The right button.
Definition MouseEvent.h:60
int y
The current y-position of the mouse, in logical pixels relative to the View.
Definition MouseEvent.h:88
Type
The various MouseEvent types.
Definition MouseEvent.h:31
@ kType_MouseMoved
Mouse moved type.
Definition MouseEvent.h:35
@ kType_MouseDown
Mouse button pressed type.
Definition MouseEvent.h:40
@ kType_MouseUp
Mouse button released type.
Definition MouseEvent.h:45
int x
The current x-position of the mouse, in logical pixels relative to the View.
Definition MouseEvent.h:83
Button button
The mouse button that was pressed/released, if any.
Definition MouseEvent.h:93
Type type
The type of this MouseEvent.
Definition MouseEvent.h:78
Root namespace for every public Ultralight type, function, and enumeration.