gtkmm 4.16.0
|
Functions for handling events from the window system. More...
#include <gdkmm/event.h>
Public Types | |
enum class | Type { DELETE , MOTION_NOTIFY , BUTTON_PRESS , BUTTON_RELEASE , KEY_PRESS , KEY_RELEASE , ENTER_NOTIFY , LEAVE_NOTIFY , FOCUS_CHANGE , PROXIMITY_IN , PROXIMITY_OUT , DRAG_ENTER , DRAG_LEAVE , DRAG_MOTION , DROP_START , SCROLL , GRAB_BROKEN , TOUCH_BEGIN , TOUCH_UPDATE , TOUCH_END , TOUCH_CANCEL , TOUCHPAD_SWIPE , TOUCHPAD_PINCH , PAD_BUTTON_PRESS , PAD_BUTTON_RELEASE , PAD_RING , PAD_STRIP , PAD_GROUP_MODE , TOUCHPAD_HOLD , EVENT_LAST } |
Public Member Functions | |
void | reference () const |
Increment the reference count for this object. | |
void | unreference () const |
Decrement the reference count for this object. | |
GdkEvent * | gobj () |
Provides access to the underlying C instance. | |
const GdkEvent * | gobj () const |
Provides access to the underlying C instance. | |
GdkEvent * | gobj_copy () const |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
Event ()=delete | |
Event (const Event &)=delete | |
Event & | operator= (const Event &)=delete |
Type | get_event_type () const |
Retrieves the type of the event. | |
Glib::RefPtr< Surface > | get_surface () |
Extracts the surface associated with an event. | |
Glib::RefPtr< const Surface > | get_surface () const |
Extracts the surface associated with an event. | |
Glib::RefPtr< Seat > | get_seat () |
Returns the seat that originated the event. | |
Glib::RefPtr< const Seat > | get_seat () const |
Returns the seat that originated the event. | |
Glib::RefPtr< Device > | get_device () |
Returns the device of an event. | |
Glib::RefPtr< const Device > | get_device () const |
Returns the device of an event. | |
Glib::RefPtr< DeviceTool > | get_device_tool () |
Returns a Gdk::DeviceTool representing the tool that caused the event. | |
Glib::RefPtr< const DeviceTool > | get_device_tool () const |
Returns a Gdk::DeviceTool representing the tool that caused the event. | |
guint32 | get_time () const |
Returns the timestamp of event. | |
Glib::RefPtr< Display > | get_display () |
Retrieves the display associated to the event. | |
Glib::RefPtr< const Display > | get_display () const |
Retrieves the display associated to the event. | |
const EventSequence * | get_event_sequence () const |
Returns the event sequence to which the event belongs. | |
ModifierType | get_modifier_state () const |
Returns the modifier state field of an event. | |
bool | get_position (double &x, double &y) const |
Extract the event surface relative x/y coordinates from an event. | |
std::vector< double > | get_axes () const |
Extracts all axis values from an event. | |
bool | get_axis (Gdk::AxisUse axis_use, double & value) const |
Extract the axis value for a particular axis use from an event structure. | |
bool | get_pointer_emulated () const |
Returns whether this event is an 'emulated' pointer event. | |
guint | get_button () const |
Extract the button number from a button event. | |
ScrollDirection | get_direction () const |
Extracts the direction of a scroll event. | |
void | get_deltas (double &delta_x, double &delta_y) const |
Extracts the scroll deltas of a scroll event. | |
ScrollUnit | get_scroll_unit () const |
Extracts the scroll delta unit of a scroll event. | |
bool | is_scroll_stop () const |
Check whether a scroll event is a stop scroll event. | |
guint | get_keyval () const |
Extracts the keyval from a key event. | |
guint | get_keycode () const |
Extracts the keycode from a key event. | |
ModifierType | get_consumed_modifiers () const |
Extracts the consumed modifiers from a key event. | |
guint | get_layout () const |
Extracts the layout from a key event. | |
guint | get_level () const |
Extracts the shift level from a key event. | |
bool | is_modifier () const |
Extracts whether the key event is for a modifier key. | |
bool | get_focus_in () const |
Extracts whether this event is about focus entering or leaving the surface. | |
bool | get_touch_emulating_pointer () const |
Extracts whether a touch event is emulating a pointer event. | |
CrossingMode | get_crossing_mode () const |
Extracts the crossing mode from a crossing event. | |
NotifyType | get_crossing_detail () const |
Extracts the notify detail from a crossing event. | |
bool | get_crossing_focus () const |
Checks if the event surface is the focus surface. | |
TouchpadGesturePhase | get_touchpad_gesture_phase () const |
Extracts the touchpad gesture phase from a touchpad event. | |
guint | get_touchpad_n_fingers () const |
Extracts the number of fingers from a touchpad event. | |
void | get_touchpad_deltas (double &dx, double &dy) const |
Extracts delta information from a touchpad event. | |
double | get_touchpad_pinch_angle_delta () const |
Extracts the angle delta from a touchpad pinch event. | |
double | get_touchpad_pinch_scale () const |
Extracts the scale from a touchpad pinch event. | |
guint | get_pad_button () const |
Extracts information about the pressed button from a pad event. | |
void | get_pad_axis_value (guint & index, double & value) const |
Extracts the information from a pad strip or ring event. | |
void | get_pad_group_mode (guint & group, guint &mode) const |
Extracts group and mode information from a pad event. | |
Glib::RefPtr< Drop > | get_dnd_drop () |
Gets the Gdk::Drop object from a DND event. | |
Glib::RefPtr< const Drop > | get_dnd_drop () const |
Gets the Gdk::Drop object from a DND event. | |
Glib::RefPtr< Surface > | get_grab_broken_grab_surface () |
Extracts the grab surface from a grab broken event. | |
Glib::RefPtr< const Surface > | get_grab_broken_grab_surface () const |
Extracts the grab surface from a grab broken event. | |
bool | get_grab_broken_implicit () const |
Checks whether the grab broken event is for an implicit grab. | |
std::vector< TimeCoord > | get_history () const |
Retrieves the history of the event, as a vector of time and coordinates. | |
bool | triggers_context_menu () const |
Returns whether a Gdk::Event should trigger a context menu, according to platform conventions. | |
bool | get_distance (const Glib::RefPtr< const Event > &event2, double &distance) const |
Returns the distance between the event locations. | |
bool | get_angle (const Glib::RefPtr< const Event > &event2, double &angle) const |
Returns the relative angle from event1 to event2. | |
bool | get_center (const Glib::RefPtr< const Event > &event2, double &x, double &y) const |
Returns the point halfway between the events' positions. | |
KeyMatch | matches (guint keyval, ModifierType modifiers) const |
Matches a key event against a keyval and modifiers. | |
bool | get_match (guint &keyval, ModifierType &modifiers) const |
Gets a keyval and modifier combination that will match the event. | |
Protected Member Functions | |
void | operator delete (void *, std::size_t) |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gdk::Event > | wrap (GdkEvent *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Functions for handling events from the window system.
In GTK applications the events are handled automatically by toplevel widgets and passed on to the event controllers of appropriate widgets, so these functions are rarely needed.
Key values are the codes which are sent whenever a key is pressed or released. The complete list of key values can be found in the gdk/gdkkeysyms.h header file. They are prefixed with GDK_KEY_
.
|
strong |
|
delete |
Returns the relative angle from event1 to event2.
The relative angle is the angle between the X axis and the line through both events' positions. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.
This assumes that both events have X/Y information. If not, this function returns false
.
event2 | Second Gdk::Event . |
angle | Return location for the relative angle between both events. |
true
if the angle could be calculated. std::vector< double > Gdk::Event::get_axes | ( | ) | const |
Extracts all axis values from an event.
bool Gdk::Event::get_axis | ( | Gdk::AxisUse | axis_use, |
double & | value | ||
) | const |
Extract the axis value for a particular axis use from an event structure.
To find out which axes are used, use Gdk::DeviceTool::get_axes() on the device tool returned by get_device_tool().
axis_use | The axis use to look for. |
value | Location to store the value found. |
true
if the specified axis was found, otherwise false
. guint Gdk::Event::get_button | ( | ) | const |
Extract the button number from a button event.
bool Gdk::Event::get_center | ( | const Glib::RefPtr< const Event > & | event2, |
double & | x, | ||
double & | y | ||
) | const |
Returns the point halfway between the events' positions.
This assumes that both events have X/Y information. If not, this function returns false
.
event2 | Second Gdk::Event . |
x | Return location for the X coordinate of the center. |
y | Return location for the Y coordinate of the center. |
true
if the center could be calculated. ModifierType Gdk::Event::get_consumed_modifiers | ( | ) | const |
Extracts the consumed modifiers from a key event.
NotifyType Gdk::Event::get_crossing_detail | ( | ) | const |
Extracts the notify detail from a crossing event.
bool Gdk::Event::get_crossing_focus | ( | ) | const |
Checks if the event surface is the focus surface.
true
if the surface is the focus surface. CrossingMode Gdk::Event::get_crossing_mode | ( | ) | const |
Extracts the crossing mode from a crossing event.
Extracts the scroll deltas of a scroll event.
The deltas will be zero unless the scroll direction is Gdk::ScrollDirection::SMOOTH.
For the representation unit of these deltas, see get_unit().
delta_x | Return location for x scroll delta. |
delta_y | Return location for y scroll delta. |
Glib::RefPtr< Device > Gdk::Event::get_device | ( | ) |
Glib::RefPtr< DeviceTool > Gdk::Event::get_device_tool | ( | ) |
Returns a Gdk::DeviceTool
representing the tool that caused the event.
If the was not generated by a device that supports different tools (such as a tablet), this function will return nullptr
.
Gdk::DeviceTool
will be constant during the application lifetime, if settings must be stored persistently across runs, see Gdk::DeviceTool::get_serial().Glib::RefPtr< const DeviceTool > Gdk::Event::get_device_tool | ( | ) | const |
Returns a Gdk::DeviceTool
representing the tool that caused the event.
If the was not generated by a device that supports different tools (such as a tablet), this function will return nullptr
.
Gdk::DeviceTool
will be constant during the application lifetime, if settings must be stored persistently across runs, see Gdk::DeviceTool::get_serial().ScrollDirection Gdk::Event::get_direction | ( | ) | const |
Extracts the direction of a scroll event.
Glib::RefPtr< Display > Gdk::Event::get_display | ( | ) |
Retrieves the display associated to the event.
Gdk::Display
. Retrieves the display associated to the event.
Gdk::Display
. bool Gdk::Event::get_distance | ( | const Glib::RefPtr< const Event > & | event2, |
double & | distance | ||
) | const |
Returns the distance between the event locations.
This assumes that both events have X/Y information. If not, this function returns false
.
event2 | Second Gdk::Event . |
distance | Return location for the distance. |
true
if the distance could be calculated. Glib::RefPtr< Drop > Gdk::Event::get_dnd_drop | ( | ) |
Gets the Gdk::Drop
object from a DND event.
Gets the Gdk::Drop
object from a DND event.
const EventSequence * Gdk::Event::get_event_sequence | ( | ) | const |
Returns the event sequence to which the event belongs.
Related touch events are connected in a sequence. Other events typically don't have event sequence information.
Type Gdk::Event::get_event_type | ( | ) | const |
Retrieves the type of the event.
Gdk::Event
Type. bool Gdk::Event::get_focus_in | ( | ) | const |
Extracts whether this event is about focus entering or leaving the surface.
true
of the focus is entering. Glib::RefPtr< Surface > Gdk::Event::get_grab_broken_grab_surface | ( | ) |
Extracts the grab surface from a grab broken event.
Extracts the grab surface from a grab broken event.
bool Gdk::Event::get_grab_broken_implicit | ( | ) | const |
Checks whether the grab broken event is for an implicit grab.
true
if the an implicit grab was broken. std::vector< TimeCoord > Gdk::Event::get_history | ( | ) | const |
Retrieves the history of the event, as a vector of time and coordinates.
The history includes events that are not delivered to the application because they occurred in the same frame as this event.
Note that only motion and scroll events record history, and motion events only if one of the mouse buttons is down.
guint Gdk::Event::get_keycode | ( | ) | const |
Extracts the keycode from a key event.
guint Gdk::Event::get_keyval | ( | ) | const |
Extracts the keyval from a key event.
guint Gdk::Event::get_layout | ( | ) | const |
Extracts the layout from a key event.
guint Gdk::Event::get_level | ( | ) | const |
Extracts the shift level from a key event.
bool Gdk::Event::get_match | ( | guint & | keyval, |
ModifierType & | modifiers | ||
) | const |
Gets a keyval and modifier combination that will match the event.
See matches().
keyval | Return location for a keyval. |
modifiers | Return location for modifiers. |
true
on success. ModifierType Gdk::Event::get_modifier_state | ( | ) | const |
Returns the modifier state field of an event.
Extracts the information from a pad strip or ring event.
index | Return location for the axis index. |
value | Return location for the axis value. |
guint Gdk::Event::get_pad_button | ( | ) | const |
Extracts information about the pressed button from a pad event.
void Gdk::Event::get_pad_group_mode | ( | guint & | group, |
guint & | mode | ||
) | const |
Extracts group and mode information from a pad event.
group | Return location for the group. |
mode | Return location for the mode. |
bool Gdk::Event::get_pointer_emulated | ( | ) | const |
Returns whether this event is an 'emulated' pointer event.
Emulated pointer events typically originate from a touch events.
true
if this event is emulated. Extract the event surface relative x/y coordinates from an event.
This position is in surface coordinates.
x | Location to put event surface x coordinate. |
y | Location to put event surface y coordinate. |
ScrollUnit Gdk::Event::get_scroll_unit | ( | ) | const |
Extracts the scroll delta unit of a scroll event.
The unit will always be Gdk::ScrollUnit::WHEEL if the scroll direction is not Gdk::ScrollDirection::SMOOTH.
Glib::RefPtr< Seat > Gdk::Event::get_seat | ( | ) |
Returns the seat that originated the event.
Gdk::Seat
. Returns the seat that originated the event.
Gdk::Seat
. Glib::RefPtr< Surface > Gdk::Event::get_surface | ( | ) |
Extracts the surface associated with an event.
Gdk::Surface
associated with the event. Extracts the surface associated with an event.
Gdk::Surface
associated with the event. guint32 Gdk::Event::get_time | ( | ) | const |
Returns the timestamp of event.
Not all events have timestamps. In that case, this function returns GDK_CURRENT_TIME.
bool Gdk::Event::get_touch_emulating_pointer | ( | ) | const |
Extracts whether a touch event is emulating a pointer event.
true
if event is emulating. Extracts delta information from a touchpad event.
dx | Return location for x. |
dy | Return location for y. |
TouchpadGesturePhase Gdk::Event::get_touchpad_gesture_phase | ( | ) | const |
Extracts the touchpad gesture phase from a touchpad event.
guint Gdk::Event::get_touchpad_n_fingers | ( | ) | const |
Extracts the number of fingers from a touchpad event.
double Gdk::Event::get_touchpad_pinch_angle_delta | ( | ) | const |
Extracts the angle delta from a touchpad pinch event.
double Gdk::Event::get_touchpad_pinch_scale | ( | ) | const |
Extracts the scale from a touchpad pinch event.
GdkEvent * Gdk::Event::gobj | ( | ) |
Provides access to the underlying C instance.
GdkEvent * Gdk::Event::gobj_copy | ( | ) | const |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
bool Gdk::Event::is_modifier | ( | ) | const |
Extracts whether the key event is for a modifier key.
true
if the event is for a modifier key. bool Gdk::Event::is_scroll_stop | ( | ) | const |
Check whether a scroll event is a stop scroll event.
Scroll sequences with smooth scroll information may provide a stop scroll event once the interaction with the device finishes, e.g. by lifting a finger. This stop scroll event is the signal that a widget may trigger kinetic scrolling based on the current velocity.
Stop scroll events always have a delta of 0/0.
true
if the event is a scroll stop event. KeyMatch Gdk::Event::matches | ( | guint | keyval, |
ModifierType | modifiers | ||
) | const |
Matches a key event against a keyval and modifiers.
This is typically used to trigger keyboard shortcuts such as Ctrl-C.
Partial matches are possible where the combination matches if the currently active group is ignored.
Note that we ignore Caps Lock for matching.
keyval | The keyval to match. |
modifiers | The modifiers to match. |
Gdk::KeyMatch
value describing whether event matches. void Gdk::Event::reference | ( | ) | const |
Increment the reference count for this object.
You should never need to do this manually - use the object via a RefPtr instead.
bool Gdk::Event::triggers_context_menu | ( | ) | const |
Returns whether a Gdk::Event
should trigger a context menu, according to platform conventions.
The right mouse button typically triggers context menus. On macOS, Control+left mouse button also triggers.
This function should always be used instead of simply checking for
[C example ellipted]
true
if the event should trigger a context menu. void Gdk::Event::unreference | ( | ) | const |
Decrement the reference count for this object.
You should never need to do this manually - use the object via a RefPtr instead.
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |