rtk.Event
¶
Holds the state of events such as mouse or keyboard action. These don't
generally need to be explicitly created but are passed along in event
handlers (e.g. rtk.Widget:onclick()
)
The type
field will be set to one of these values.
rtk.Event.MOUSEDOWN¶ | A mouse button was pressed ( |
rtk.Event.MOUSEUP¶ | A mouse button was released ( |
rtk.Event.MOUSEMOVE¶ | The mouse cursor was moved. Note that in certain situations this event
can fire even when the mouse hasn't moved, for example to trigger an
|
rtk.Event.MOUSEWHEEL¶ | The mouse wheel was moved ( |
rtk.Event.KEY¶ | A key was pressed on the keyboard ( |
rtk.Event.DROPFILE¶ | One or more files were dragged and dropped over the widget ( |
rtk.Event.WINDOWCLOSE¶ | The main window is just about to close. This is a notification-only event as currently there is no way to abort closure of the main window. |
type¶ | typeconst | read-only |
Type of event which is set to one of the type constants |
handled¶ | rtk.Widget or nil | read-only |
The |
button¶ | number | read-only |
The mouse button that was the cause of the event, whether pressed or released,
according to the mouse button constants. For |
buttons¶ | number | read-only |
A bitmap of all mouse buttons currently pressed. Note that
for |
wheel¶ | number | read-only |
The vertical scroll wheel distance for |
hwheel¶ | number | read-only |
Like |
char¶ | string | read-only |
A single-character string containing the printable character of the key, if
available. Is nil if not translatable into a printable character. The shift
modifier is preserved here, so for example if the user presses shift-f then
|
keycode¶ | number | read-only |
The raw numeric keycode of the |
keynorm¶ | number | read-only |
Normalized keycode which ignores modifiers. In other words, the |
ctrl¶ | boolean | read-only |
True if the control key was held during the |
shift¶ | boolean | read-only |
True if the shift key was held during the |
alt¶ | boolean | read-only |
True if the alt key was held during the |
meta¶ | boolean | read-only |
True if the meta key (Windows key, for example) was held during the |
modifiers¶ | number | read-only |
A low-level bitmap of key event modifiers. 4=ctrl, 8=shift, 16=alt, 32=meta |
files¶ | table | read-only |
Set for |
x¶ | number | read-only |
The x client coordinate of the mouse cursor relative to the left edge of the |
y¶ | number | read-only |
The y client coordinate of the mouse cursor relative to the top edge of the |
time¶ | number | read-only |
Timestamp when the event occurred according to |
tick¶ | number | read-only |
The value of |
simulated¶ | boolean | read-only |
If true, this is a simulated |
debug¶ | boolean | read-only |
If not nil, is the |
rtk.Event() | Creates a new event |
reset() | Resets all fields in the event and sets to the given type |
is_mouse_event() | Checks if the event is related to the mouse |
get_button_duration() | Determine how long a mouse button has been pressed and held |
set_widget_mouseover() | Marks the given widget as having the mouse over it for this event |
set_modifiers() | Set the various modifier attributes according to the mouse/keyboard
modifier state (per REAPER's |
set_handled() | Marks the event as having been |
clone() | Clone the event |
Creates a new event.
attrs | (table or nil) | optional table of attributes to initialize the event with |
(rtk.Event) | the newly constructed event |
Resets all fields in the event and sets to the given type
type | (typeconst) | the type of event |
Checks if the event is related to the mouse.
(boolean) | true if the event is a mouse-related event, false otherwise. |
Determine how long a mouse button has been pressed and held.
button | (rtk.mouse or nil) | mouse button constant, or nil to use the current value of the event's |
(number or nil) | the amount of time in seconds the mouse button was held for, or nil if the mouse button is not current pressed |
Marks the given widget as having the mouse over it for this event.
The main purpose of this method is tracking which widgets should be debugged but may have other purposes in future.
Set the various modifier attributes according to the mouse/keyboard
modifier state (per REAPER's gfx.mouse_cap
).
This is called by rtk.Window
when a new event is generated.
cap | (number) | the bitmap containing mouse/keyboard state |
button | (number) | the specific mouse button that triggered the event per mouse button constants |
Marks the event as having been handled
.
Once an event is handled, it won't be actioned by any other widget. So event handlers can prevent handlers for other widgets with lower z-indexes from responding to an event by calling this method.
widget | (rtk.Widget or nil) | the widget that handled the event |
Clone the event.
overrides | (table) | replaces the attributes in the cloned event with the given table. |
(rtk.Widget) | a new event object |