Responder
Base class of Window and View for event processing.
Module | require("yue.gui") |
Type | Class |
Methods
setcapture()
Set mouse capture to the responder.
releasecapture()
Release mouse capture if the responder has mouse capture.
hascapture()
Return whether the responder has mouse capture.
Return
boolean
Linux macOS
getnative()Return a light userdata containing the pointer of underlying native widget wrapped by the responder.
On Linux the C++ type of the pointer is GtkWidget*
, and on macOS it is
NSResponder*
. The actual subclass type depends on which type this
responder is, for example for Window
you can expect the native type to
be GtkWindow*
on Linux and NSWindow*
on macOS, and for View
it would
be GtkWidget*
on Linux and NSView*
on macOS.
However for subclasses of View
, the native type is not specified, you
may find out the information by looking into the source code, but the type
might be changed in future updates. For example, the native type of
TextEdit
is currently a GtkScrolledWindow*
with a GtkTextView*
in
it, but we may want to replace it with a custom widget when adding more
features in future.
Return
userdata
Events
onmousedown(self, event)
Emitted when pressing mouse buttons.
Parameters
Responder
selfMouseEvent
event
Preventable
Yes.onmouseup(self, event)
Emitted when releasing mouse buttons.
Parameters
Responder
selfMouseEvent
event
Preventable
Yes.onmousemove(self, event)
Emitted when user moves mouse in the responder.
Parameters
Responder
selfMouseEvent
event
Preventable
No.onmouseenter(self, event)
Emitted when mouse enters the responder.
Parameters
Responder
selfMouseEvent
event
Preventable
No.onmouseleave(self, event)
Emitted when mouse leaves the responder.
Parameters
Responder
selfMouseEvent
event
Preventable
No.onkeydown(self, event)
Emitted when pressing keyboard.
Parameters
Preventable
Yes.onkeyup(self, event)
Emitted when releasing keyboard.
Parameters
Preventable
Yes.oncapturelost(self)
Emitted when the mouse capture on responder has been released.
Parameters
Responder
self