Gdk.Event¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
any |
r/w |
||
button |
r/w |
||
configure |
r/w |
||
crossing |
r/w |
||
dnd |
r/w |
||
expose |
r/w |
||
focus_change |
r/w |
||
grab_broken |
r/w |
||
key |
r/w |
||
motion |
r/w |
||
owner_change |
r/w |
||
pad_axis |
r/w |
||
pad_button |
r/w |
||
pad_group_mode |
r/w |
||
property |
r/w |
||
proximity |
r/w |
||
scroll |
r/w |
||
selection |
r/w |
||
setting |
r/w |
||
touch |
r/w |
||
touchpad_pinch |
r/w |
||
touchpad_swipe |
r/w |
||
type |
r/w |
the |
|
visibility |
r/w |
||
window_state |
r/w |
Methods¶
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Gdk.Event¶
- classmethod get()[source]¶
- Returns:
the next
Gdk.Event
to be processed, orNone
if no events are pending. The returnedGdk.Event
should be freed withGdk.Event.free
().- Return type:
Checks all open displays for a
Gdk.Event
to process,to be processed on, fetching events from the windowing system if necessary. SeeGdk.Display.get_event
().
- classmethod handler_set(func, *data)[source]¶
- Parameters:
func (
Gdk.EventFunc
) – the function to call to handle events from GDK.
Sets the function to call to handle all events from GDK.
Note that GTK+ uses this to install its own event handler, so it is usually not useful for GTK+ applications. (Although an application can call this function then call gtk_main_do_event() to pass events to GTK+.)
- classmethod new(type)[source]¶
- Parameters:
type (
Gdk.EventType
) – aGdk.EventType
- Returns:
a newly-allocated
Gdk.Event
. The returnedGdk.Event
should be freed withGdk.Event.free
().- Return type:
Creates a new event of the given type. All fields are set to 0.
New in version 2.2.
- classmethod peek()[source]¶
- Returns:
a copy of the first
Gdk.Event
on some event queue, orNone
if no events are in any queues. The returnedGdk.Event
should be freed withGdk.Event.free
().- Return type:
If there is an event waiting in the event queue of some open display, returns a copy of it. See
Gdk.Display.peek_event
().
- classmethod request_motions(event)[source]¶
- Parameters:
event (
Gdk.EventMotion
) – a validGdk.Event
Request more motion notifies if event is a motion notify hint event.
This function should be used instead of
Gdk.Window.get_pointer
() to request further motion notifies, because it also works for extension events where motion notifies are provided for devices other than the core pointer. Coordinate extraction, processing and requesting more motion events from aGdk.EventType.MOTION_NOTIFY
event usually works like this:{ // motion_event handler x = motion_event->x; y = motion_event->y; // handle (x,y) motion gdk_event_request_motions (motion_event); // handles is_hint events }
New in version 2.12.
- copy()[source]¶
- Returns:
a copy of self. The returned
Gdk.Event
should be freed withGdk.Event.free
().- Return type:
Copies a
Gdk.Event
, copying or incrementing the reference count of the resources associated with it (e.g.Gdk.Window
’s and strings).
- free()[source]¶
Frees a
Gdk.Event
, freeing or decrementing any resources associated with it. Note that this function should only be called with events returned from functions such asGdk.Event.peek
(),Gdk.Event.get
(),Gdk.Event.copy
() andGdk.Event.new
().
- get_axis(axis_use)[source]¶
- Parameters:
axis_use (
Gdk.AxisUse
) – the axis use to look for- Returns:
True
if the specified axis was found, otherwiseFalse
- value:
location to store the value found
- Return type:
Extract the axis value for a particular axis use from an event structure.
- get_button()[source]¶
- Returns:
True
if the event delivered a button number- button:
location to store mouse button number
- Return type:
Extract the button number from an event.
New in version 3.2.
- get_click_count()[source]¶
- Returns:
True
if the event delivered a click count- click_count:
location to store click count
- Return type:
Extracts the click count from an event.
New in version 3.2.
- get_coords()[source]¶
- Returns:
True
if the event delivered event window coordinates- x_win:
location to put event window x coordinate
- y_win:
location to put event window y coordinate
- Return type:
Extract the event window relative x/y coordinates from an event.
- get_device()[source]¶
- Returns:
a
Gdk.Device
, orNone
.- Return type:
Gdk.Device
orNone
If the event contains a “device” field, this function will return it, else it will return
None
.New in version 3.0.
- get_device_tool()[source]¶
- Returns:
The current device tool, or
None
- Return type:
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,None
will be returned.Note: the
Gdk.DeviceTool
s will be constant during the application lifetime, if settings must be stored persistently across runs, seeGdk.DeviceTool.get_serial
()New in version 3.22.
- get_event_sequence()[source]¶
- Returns:
the event sequence that the event belongs to
- Return type:
If self if of type
Gdk.EventType.TOUCH_BEGIN
,Gdk.EventType.TOUCH_UPDATE
,Gdk.EventType.TOUCH_END
orGdk.EventType.TOUCH_CANCEL
, returns theGdk.EventSequence
to which the event belongs. Otherwise, returnNone
.New in version 3.4.
- get_event_type()[source]¶
- Returns:
- Return type:
Retrieves the type of the event.
New in version 3.10.
- get_keycode()[source]¶
- Returns:
True
if the event delivered a hardware keycode- keycode:
location to store the keycode
- Return type:
Extracts the hardware keycode from an event.
Also see
Gdk.Event.get_scancode
().New in version 3.2.
- get_keyval()[source]¶
- Returns:
True
if the event delivered a key symbol- keyval:
location to store the keyval
- Return type:
Extracts the keyval from an event.
New in version 3.2.
- get_pointer_emulated()[source]¶
-
#event: a
Gdk.Event
Returns whether this event is an ‘emulated’ pointer event (typically from a touch event), as opposed to a real one.New in version 3.22.
- get_root_coords()[source]¶
- Returns:
True
if the event delivered root window coordinates- x_root:
location to put root window x coordinate
- y_root:
location to put root window y coordinate
- Return type:
Extract the root window relative x/y coordinates from an event.
- get_scancode()[source]¶
- Returns:
The associated keyboard scancode or 0
- Return type:
Gets the keyboard low-level scancode of a key event.
This is usually hardware_keycode. On Windows this is the high word of WM_KEY{DOWN,UP} lParam which contains the scancode and some extended flags.
New in version 3.22.
- get_screen()[source]¶
- Returns:
the screen for the event
- Return type:
Returns the screen for the event. The screen is typically the screen for
event->any.window
, but for events such as mouse events, it is the screen where the pointer was when the event occurs - that is, the screen which has the root window to whichevent->motion.x_root
andevent->motion.y_root
are relative.New in version 2.2.
- get_scroll_deltas()[source]¶
- Returns:
True
if the event contains smooth scroll information andFalse
otherwise- delta_x:
return location for X delta
- delta_y:
return location for Y delta
- Return type:
Retrieves the scroll deltas from a
Gdk.Event
See also:
Gdk.Event.get_scroll_direction
()New in version 3.4.
- get_scroll_direction()[source]¶
- Returns:
True
if the event delivered a scroll direction andFalse
otherwise- direction:
location to store the scroll direction
- Return type:
(
bool
, direction:Gdk.ScrollDirection
)
Extracts the scroll direction from an event.
If self is not of type
Gdk.EventType.SCROLL
, the contents of direction are undefined.If you wish to handle both discrete and smooth scrolling, you should check the return value of this function, or of
Gdk.Event.get_scroll_deltas
(); for instance:GdkScrollDirection direction; double vscroll_factor = 0.0; double x_scroll, y_scroll; if (gdk_event_get_scroll_direction (event, &direction)) { // Handle discrete scrolling with a known constant delta; const double delta = 12.0; switch (direction) { case GDK_SCROLL_UP: vscroll_factor = -delta; break; case GDK_SCROLL_DOWN: vscroll_factor = delta; break; default: // no scrolling break; } } else if (gdk_event_get_scroll_deltas (event, &x_scroll, &y_scroll)) { // Handle smooth scrolling directly vscroll_factor = y_scroll; }
New in version 3.2.
- get_source_device()[source]¶
- Returns:
a
Gdk.Device
, orNone
.- Return type:
Gdk.Device
orNone
This function returns the hardware (slave)
Gdk.Device
that has triggered the event, falling back to the virtual (master) device (as inGdk.Event.get_device
()) if the event wasn’t caused by interaction with a hardware device. This may happen for example in synthesized crossing events after aGdk.Window
updates its geometry or a grab is acquired/released.If the event does not contain a device field, this function will return
None
.New in version 3.0.
- get_state()[source]¶
- Returns:
True
if there was a state field in the event- state:
return location for state
- Return type:
(
bool
, state:Gdk.ModifierType
)
If the event contains a “state” field, puts that field in state. Otherwise stores an empty state (0). Returns
True
if there was a state field in the event. self may beNone
, in which case it’s treated as if the event had no state field.
- get_time()[source]¶
- Returns:
time stamp field from self
- Return type:
Returns the time stamp from self, if there is one; otherwise returns
Gdk.CURRENT_TIME
. If self isNone
, returnsGdk.CURRENT_TIME
.
- get_window()[source]¶
- Returns:
The
Gdk.Window
associated with the event- Return type:
Extracts the
Gdk.Window
associated with an event.New in version 3.10.
- is_scroll_stop_event()[source]¶
-
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 a delta of 0/0.
New in version 3.20.
- put()[source]¶
Appends a copy of the given event onto the front of the event queue for event->any.window’s display, or the default event queue if event->any.window is
None
. SeeGdk.Display.put_event
().
- set_device(device)[source]¶
- Parameters:
device (
Gdk.Device
) – aGdk.Device
Sets the device for self to device. The event must have been allocated by GTK+, for instance, by
Gdk.Event.copy
().New in version 3.0.
- set_device_tool(tool)[source]¶
- Parameters:
tool (
Gdk.DeviceTool
orNone
) – tool to set on the event, orNone
Sets the device tool for this event, should be rarely used.
New in version 3.22.
- set_screen(screen)[source]¶
- Parameters:
screen (
Gdk.Screen
) – aGdk.Screen
Sets the screen for self to screen. The event must have been allocated by GTK+, for instance, by
Gdk.Event.copy
().New in version 2.2.
- set_source_device(device)[source]¶
- Parameters:
device (
Gdk.Device
) – aGdk.Device
Sets the slave device for self to device.
The event must have been allocated by GTK+, for instance by
Gdk.Event.copy
().New in version 3.0.
-
This function returns whether a
Gdk.EventButton
should trigger a context menu, according to platform conventions. The right mouse button always triggers context menus. Additionally, ifGdk.Keymap.get_modifier_mask
() returns a non-0 mask forGdk.ModifierIntent.CONTEXT_MENU
, then the left mouse button will also trigger a context menu if this modifier is pressed.This function should always be used instead of simply checking for event->button ==
Gdk.BUTTON_SECONDARY
.New in version 3.4.