gtkmm: Gdk::Event Class Reference
Functions for handling events from the window system. More...
#include <gdkmm/event.h>
Public Member Functions | |
void | reference () const |
Increment the reference count for this object. More... | |
void | unreference () const |
Decrement the reference count for this object. More... | |
GdkEvent* | gobj () |
Provides access to the underlying C instance. More... | |
const GdkEvent* | gobj () const |
Provides access to the underlying C instance. More... | |
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. More... | |
Event ()=delete | |
Event (const Event&)=delete | |
Event& | operator= (const Event&)=delete |
Type | get_event_type () const |
Retrieves the type of the event. More... | |
Glib::RefPtr< Surface > | get_surface () |
Extracts the Gdk::Surface associated with an event. More... | |
Glib::RefPtr< const Surface > | get_surface () const |
Extracts the Gdk::Surface associated with an event. More... | |
Glib::RefPtr< Seat > | get_seat () |
Returns the seat that originated the event. More... | |
Glib::RefPtr< const Seat > | get_seat () const |
Returns the seat that originated the event. More... | |
Glib::RefPtr< Device > | get_device () |
Returns the device of an event. More... | |
Glib::RefPtr< const Device > | get_device () const |
Returns the device of an event. More... | |
Glib::RefPtr< DeviceTool > | get_device_tool () |
If the event was generated by a device that supports different tools (eg. More... | |
Glib::RefPtr< const DeviceTool > | get_device_tool () const |
If the event was generated by a device that supports different tools (eg. More... | |
guint32 | get_time () const |
Returns the time stamp from event, if there is one; otherwise returns GDK_CURRENT_TIME. More... | |
Glib::RefPtr< Display > | get_display () |
Retrieves the Gdk::Display associated to the event. More... | |
Glib::RefPtr< const Display > | get_display () const |
Retrieves the Gdk::Display associated to the event. More... | |
const EventSequence* | get_event_sequence () const |
If event is a touch event, returns the Gdk::EventSequence to which the event belongs. More... | |
ModifierType | get_modifier_state () const |
Returns the modifier state field of an event. More... | |
bool | get_position (double& x, double& y) const |
Extract the event surface relative x/y coordinates from an event. More... | |
std::vector< double > | get_axes () const |
Extracts all axis values from an event. More... | |
bool | get_axis (Gdk::AxisUse axis_use, double& value) const |
Extract the axis value for a particular axis use from an event structure. More... | |
bool | get_pointer_emulated () const |
Returns whether this event is an 'emulated' pointer event (typically from a touch event), as opposed to a real one. More... | |
guint | get_button () const |
Extract the button number from a button event. More... | |
ScrollDirection | get_direction () const |
Extracts the direction of a scroll event. More... | |
void | get_deltas (double& delta_x, double& delta_y) const |
Extracts the scroll deltas of a scroll event. More... | |
bool | is_scroll_stop () const |
Check whether a scroll event is a stop scroll event. More... | |
guint | get_keyval () const |
Extracts the keyval from a key event. More... | |
guint | get_keycode () const |
Extracts the keycode from a key event. More... | |
ModifierType | get_consumed_modifiers () const |
Extracts the consumed modifiers from a key event. More... | |
guint | get_layout () const |
Extracts the layout from a key event. More... | |
guint | get_level () const |
Extracts the shift level from a key event. More... | |
bool | is_modifier () const |
Extracts whether the key event is for a modifier key. More... | |
bool | get_focus_in () const |
Extracts whether this event is about focus entering or leaving the surface. More... | |
bool | get_touch_emulating_pointer () const |
Extracts whether a touch event is emulating a pointer event. More... | |
CrossingMode | get_crossing_mode () const |
Extracts the crossing mode from a crossing event. More... | |
NotifyType | get_crossing_detail () const |
Extracts the notify detail from a crossing event. More... | |
bool | get_crossing_focus () const |
Checks if the event surface is the focus surface. More... | |
TouchpadGesturePhase | get_touchpad_gesture_phase () const |
Extracts the touchpad gesture phase from a touchpad event. More... | |
guint | get_touchpad_n_fingers () const |
Extracts the number of fingers from a touchpad event. More... | |
void | get_touchpad_deltas (double& dx, double& dy) const |
Extracts delta information from a touchpad event. More... | |
double | get_touchpad_pinch_angle_delta () const |
Extracts the angle delta from a touchpad pinch event. More... | |
double | get_touchpad_pinch_scale () const |
Extracts the scale from a touchpad pinch event. More... | |
guint | get_pad_button () const |
Extracts information about the pressed button from a pad event. More... | |
void | get_pad_axis_value (guint& index, double& value) const |
Extracts the information from a pad strip or ring event. More... | |
void | get_pad_group_mode (guint& group, guint& mode) const |
Extracts group and mode information from a pad event. More... | |
Glib::RefPtr< Drop > | get_dnd_drop () |
Gets the Gdk::Drop from a DND event. More... | |
Glib::RefPtr< const Drop > | get_dnd_drop () const |
Gets the Gdk::Drop from a DND event. More... | |
Glib::RefPtr< Surface > | get_grab_broken_grab_surface () |
Extracts the grab surface from a grab broken event. More... | |
Glib::RefPtr< const Surface > | get_grab_broken_grab_surface () const |
Extracts the grab surface from a grab broken event. More... | |
bool | get_grab_broken_implicit () const |
Checks whether the grab broken event is for an implicit grab. More... | |
std::vector< TimeCoord > | get_history () const |
Retrieves the history of the event, as a vector of time and coordinates. More... | |
bool | triggers_context_menu () const |
This function returns whether a Gdk::Event should trigger a context menu, according to platform conventions. More... | |
bool | get_distance (const Glib::RefPtr< const Event >& event2, double&distance) const |
If both events have X/Y information, the distance between both coordinates (as in a straight line going from event1 to event2) will be returned. More... | |
bool | get_angle (const Glib::RefPtr< const Event >& event2, double& angle) const |
If both events contain X/Y information, this function will return true and return in angle the relative angle from event1 to event2. More... | |
bool | get_center (const Glib::RefPtr< const Event >& event2, double& x, double& y) const |
If both events contain X/Y information, the center of both coordinates will be returned in x and y. More... | |
KeyMatch | matches (guint keyval, ModifierType modifiers) const |
Matches a key event against a keyboard shortcut that is specified as a keyval and modifiers. More... | |
bool | get_match (guint& keyval, ModifierType& modifiers) const |
Gets a keyval and modifier combination that will cause gdk_key_event_matches() to successfully match the given event. More... | |
Protected Member Functions | |
void | operator delete (void*, std::size_t) |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr< Gdk::Event > | wrap (GdkEvent* object, bool take_copy=false) |
A Glib::wrap() method for this object. More... | |
Detailed Description
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_
.
Constructor & Destructor Documentation
|
delete |
|
delete |
Member Function Documentation
bool Gdk::Event::get_angle | ( | const Glib::RefPtr< const Event >& | event2, |
double & | angle | ||
) | const |
If both events contain X/Y information, this function will return true
and return in angle the relative angle from event1 to event2.
The rotation direction for positive angles is from the positive X axis towards the positive Y axis.
- Parameters
-
event2 Second Gdk::Event. angle Return location for the relative angle between both events.
- Returns
true
if the angle could be calculated.
std::vector<double> Gdk::Event::get_axes | ( | ) | const |
Extracts all axis values from an event.
- Returns
- A vector of values for all axes. An empty vector in case of failure.
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.
- Parameters
-
axis_use The axis use to look for. value Location to store the value found.
- Returns
true
if the specified axis was found, otherwisefalse
.
guint Gdk::Event::get_button | ( | ) | const |
Extract the button number from a button event.
- Returns
- The button of event.
bool Gdk::Event::get_center | ( | const Glib::RefPtr< const Event >& | event2, |
double & | x, | ||
double & | y | ||
) | const |
If both events contain X/Y information, the center of both coordinates will be returned in x and y.
- Parameters
-
event2 Second Gdk::Event. x Return location for the X coordinate of the center. y Return location for the Y coordinate of the center.
- Returns
true
if the center could be calculated.
ModifierType Gdk::Event::get_consumed_modifiers | ( | ) | const |
Extracts the consumed modifiers from a key event.
- Returns
- The consumed modifiers or event.
NotifyType Gdk::Event::get_crossing_detail | ( | ) | const |
Extracts the notify detail from a crossing event.
- Returns
- The notify detail of event.
bool Gdk::Event::get_crossing_focus | ( | ) | const |
Checks if the event surface is the focus surface.
- Returns
true
if the surface is the focus surface.
CrossingMode Gdk::Event::get_crossing_mode | ( | ) | const |
Extracts the crossing mode from a crossing event.
- Returns
- The mode of event.
void Gdk::Event::get_deltas | ( | double & | delta_x, |
double & | delta_y | ||
) | const |
Extracts the scroll deltas of a scroll event.
The deltas will be zero unless the scroll direction is Gdk::ScrollDirection::SMOOTH.
- Parameters
-
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<const Device> Gdk::Event::get_device | ( | ) | const |
Glib::RefPtr<DeviceTool> Gdk::Event::get_device_tool | ( | ) |
If the event was generated by a device that supports different tools (eg.
a tablet), this function will return a Gdk::DeviceTool representing the tool that caused the event. Otherwise, nullptr
will be returned.
- Note
- the Gdk::DeviceTools will be constant during the application lifetime, if settings must be stored persistently across runs, see Gdk::DeviceTool::get_serial()
- Returns
- The current device tool, or
nullptr
.
Glib::RefPtr<const DeviceTool> Gdk::Event::get_device_tool | ( | ) | const |
If the event was generated by a device that supports different tools (eg.
a tablet), this function will return a Gdk::DeviceTool representing the tool that caused the event. Otherwise, nullptr
will be returned.
- Note
- the Gdk::DeviceTools will be constant during the application lifetime, if settings must be stored persistently across runs, see Gdk::DeviceTool::get_serial()
- Returns
- The current device tool, or
nullptr
.
ScrollDirection Gdk::Event::get_direction | ( | ) | const |
Extracts the direction of a scroll event.
- Returns
- The scroll direction of event.
Glib::RefPtr<Display> Gdk::Event::get_display | ( | ) |
Retrieves the Gdk::Display associated to the event.
- Returns
- A Gdk::Display.
Glib::RefPtr<const Display> Gdk::Event::get_display | ( | ) | const |
Retrieves the Gdk::Display associated to the event.
- Returns
- A Gdk::Display.
bool Gdk::Event::get_distance | ( | const Glib::RefPtr< const Event >& | event2, |
double & | distance | ||
) | const |
If both events have X/Y information, the distance between both coordinates (as in a straight line going from event1 to event2) will be returned.
- Parameters
-
event2 Second Gdk::Event. distance Return location for the distance.
- Returns
true
if the distance could be calculated.
Glib::RefPtr<Drop> Gdk::Event::get_dnd_drop | ( | ) |
Gets the Gdk::Drop from a DND event.
- Returns
- The drop.
Glib::RefPtr<const Drop> Gdk::Event::get_dnd_drop | ( | ) | const |
Gets the Gdk::Drop from a DND event.
- Returns
- The drop.
const EventSequence* Gdk::Event::get_event_sequence | ( | ) | const |
If event is a touch event, returns the Gdk::EventSequence to which the event belongs.
Otherwise, return nullptr
.
- Returns
- The event sequence that the event belongs to.
Type Gdk::Event::get_event_type | ( | ) | const |
Retrieves the type of the event.
- Returns
- A Gdk::Event::Type.
bool Gdk::Event::get_focus_in | ( | ) | const |
Extracts whether this event is about focus entering or leaving the surface.
- Returns
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.
- Returns
- The grab surface of event.
Glib::RefPtr<const Surface> Gdk::Event::get_grab_broken_grab_surface | ( | ) | const |
Extracts the grab surface from a grab broken event.
- Returns
- The grab surface of event.
bool Gdk::Event::get_grab_broken_implicit | ( | ) | const |
Checks whether the grab broken event is for an implicit grab.
- Returns
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.
- Returns
- A vector of time and coordinates.
guint Gdk::Event::get_keycode | ( | ) | const |
Extracts the keycode from a key event.
- Returns
- The keycode of event.
guint Gdk::Event::get_keyval | ( | ) | const |
Extracts the keyval from a key event.
- Returns
- The keyval of event.
guint Gdk::Event::get_layout | ( | ) | const |
Extracts the layout from a key event.
- Returns
- The layout of event.
guint Gdk::Event::get_level | ( | ) | const |
Extracts the shift level from a key event.
- Returns
- The shift level of event.
bool Gdk::Event::get_match | ( | guint & | keyval, |
ModifierType& | modifiers | ||
) | const |
Gets a keyval and modifier combination that will cause gdk_key_event_matches() to successfully match the given event.
- Parameters
-
keyval Return location for a keyval. modifiers Return location for modifiers.
- Returns
true
on success.
ModifierType Gdk::Event::get_modifier_state | ( | ) | const |
Returns the modifier state field of an event.
- Returns
- The modifier state of event.
void Gdk::Event::get_pad_axis_value | ( | guint & | index, |
double & | value | ||
) | const |
Extracts the information from a pad strip or ring event.
- Parameters
-
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.
- Returns
- The button of event.
void Gdk::Event::get_pad_group_mode | ( | guint & | group, |
guint & | mode | ||
) | const |
Extracts group and mode information from a pad event.
- Parameters
-
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 (typically from a touch event), as opposed to a real one.
- Returns
true
if this event is emulated.
bool Gdk::Event::get_position | ( | double & | x, |
double & | y | ||
) | const |
Extract the event surface relative x/y coordinates from an event.
- Parameters
-
x Location to put event surface x coordinate. y Location to put event surface y coordinate.
Glib::RefPtr<Seat> Gdk::Event::get_seat | ( | ) |
Returns the seat that originated the event.
- Returns
- A Gdk::Seat.
Glib::RefPtr<const Seat> Gdk::Event::get_seat | ( | ) | const |
Returns the seat that originated the event.
- Returns
- A Gdk::Seat.
Glib::RefPtr<Surface> Gdk::Event::get_surface | ( | ) |
Extracts the Gdk::Surface associated with an event.
- Returns
- The Gdk::Surface associated with the event.
Glib::RefPtr<const Surface> Gdk::Event::get_surface | ( | ) | const |
Extracts the Gdk::Surface associated with an event.
- Returns
- The Gdk::Surface associated with the event.
guint32 Gdk::Event::get_time | ( | ) | const |
Returns the time stamp from event, if there is one; otherwise returns GDK_CURRENT_TIME.
- Returns
- Time stamp field from event.
bool Gdk::Event::get_touch_emulating_pointer | ( | ) | const |
Extracts whether a touch event is emulating a pointer event.
- Returns
true
if event is emulating.
void Gdk::Event::get_touchpad_deltas | ( | double & | dx, |
double & | dy | ||
) | const |
Extracts delta information from a touchpad event.
- Parameters
-
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.
- Returns
- The gesture phase of event.
guint Gdk::Event::get_touchpad_n_fingers | ( | ) | const |
Extracts the number of fingers from a touchpad event.
- Returns
- The number of fingers for event.
double Gdk::Event::get_touchpad_pinch_angle_delta | ( | ) | const |
Extracts the angle delta from a touchpad pinch event.
- Returns
- The angle delta of event.
double Gdk::Event::get_touchpad_pinch_scale | ( | ) | const |
Extracts the scale from a touchpad pinch event.
- Returns
- The scale of event.
GdkEvent* Gdk::Event::gobj | ( | ) |
Provides access to the underlying C instance.
const GdkEvent* Gdk::Event::gobj | ( | ) | const |
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.
- Returns
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.
- Returns
true
if the event is a scroll stop event.
KeyMatch Gdk::Event::matches | ( | guint | keyval, |
ModifierType | modifiers | ||
) | const |
Matches a key event against a keyboard shortcut that is specified as a keyval and modifiers.
Partial matches are possible where the combination matches if the currently active group is ignored.
Note that we ignore Caps Lock for matching.
- Parameters
-
keyval The keyval to match. modifiers The modifiers to match.
- Returns
- A GdkKeyMatch value describing whether event matches.
|
protected |
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 |
This function returns whether a Gdk::Event should trigger a context menu, according to platform conventions.
The right mouse button always triggers context menus.
This function should always be used instead of simply checking for event->button == GDK_BUTTON_SECONDARY.
- Returns
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.
Friends And Related Function Documentation
|
related |
A Glib::wrap() method for this object.
- Parameters
-
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.
- Returns
- A C++ instance that wraps this C instance.