Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
- Exported types
- Methods
- Overloaded methods
- copy
- free
- get
- getAxis
- getButton
- getClickCount
- getCoords
- getDevice
- getDeviceTool
- getEventSequence
- getEventType
- getKeycode
- getKeyval
- getPointerEmulated
- getRootCoords
- getScancode
- getScreen
- getScrollDeltas
- getScrollDirection
- getSeat
- getSourceDevice
- getState
- getTime
- getWindow
- handlerSet
- isScrollStopEvent
- new
- peek
- put
- requestMotions
- setDevice
- setDeviceTool
- setScreen
- setSourceDevice
- triggersContextMenu
- Properties
A Event
contains a union of all of the event types,
and allows access to the data fields in a number of ways.
The event type is always the first field in all of the event types, and can always be accessed with the following code, no matter what type of event it is:
C code
GdkEvent *event; GdkEventType type; type = event->type;
To access other fields of the event, the pointer to the event
can be cast to the appropriate event type, or the union member
name can be used. For example if the event type is EventTypeButtonPress
then the x coordinate of the button press can be accessed with:
C code
GdkEvent *event; gdouble x; x = ((GdkEventButton*)event)->x;
or:
C code
GdkEvent *event; gdouble x; x = event->button.x;
Synopsis
- newtype Event = Event (ManagedPtr Event)
- newZeroEvent :: MonadIO m => m Event
- eventCopy :: (HasCallStack, MonadIO m) => Event -> m Event
- eventFree :: (HasCallStack, MonadIO m) => Event -> m ()
- eventGet :: (HasCallStack, MonadIO m) => m (Maybe Event)
- eventGetAxis :: (HasCallStack, MonadIO m) => Event -> AxisUse -> m (Bool, Double)
- eventGetButton :: (HasCallStack, MonadIO m) => Event -> m (Bool, Word32)
- eventGetClickCount :: (HasCallStack, MonadIO m) => Event -> m (Bool, Word32)
- eventGetCoords :: (HasCallStack, MonadIO m) => Event -> m (Bool, Double, Double)
- eventGetDevice :: (HasCallStack, MonadIO m) => Event -> m (Maybe Device)
- eventGetDeviceTool :: (HasCallStack, MonadIO m) => Event -> m DeviceTool
- eventGetEventSequence :: (HasCallStack, MonadIO m) => Event -> m EventSequence
- eventGetEventType :: (HasCallStack, MonadIO m) => Event -> m EventType
- eventGetKeycode :: (HasCallStack, MonadIO m) => Event -> m (Bool, Word16)
- eventGetKeyval :: (HasCallStack, MonadIO m) => Event -> m (Bool, Word32)
- eventGetPointerEmulated :: (HasCallStack, MonadIO m) => Event -> m Bool
- eventGetRootCoords :: (HasCallStack, MonadIO m) => Event -> m (Bool, Double, Double)
- eventGetScancode :: (HasCallStack, MonadIO m) => Event -> m Int32
- eventGetScreen :: (HasCallStack, MonadIO m) => Event -> m Screen
- eventGetScrollDeltas :: (HasCallStack, MonadIO m) => Event -> m (Bool, Double, Double)
- eventGetScrollDirection :: (HasCallStack, MonadIO m) => Event -> m (Bool, ScrollDirection)
- eventGetSeat :: (HasCallStack, MonadIO m) => Event -> m Seat
- eventGetSourceDevice :: (HasCallStack, MonadIO m) => Event -> m (Maybe Device)
- eventGetState :: (HasCallStack, MonadIO m) => Event -> m (Bool, [ModifierType])
- eventGetTime :: (HasCallStack, MonadIO m) => Event -> m Word32
- eventGetWindow :: (HasCallStack, MonadIO m) => Event -> m Window
- eventHandlerSet :: (HasCallStack, MonadIO m) => EventFunc -> m ()
- eventIsScrollStopEvent :: (HasCallStack, MonadIO m) => Event -> m Bool
- eventNew :: (HasCallStack, MonadIO m) => EventType -> m Event
- eventPeek :: (HasCallStack, MonadIO m) => m (Maybe Event)
- eventPut :: (HasCallStack, MonadIO m) => Event -> m ()
- eventRequestMotions :: (HasCallStack, MonadIO m) => EventMotion -> m ()
- eventSetDevice :: (HasCallStack, MonadIO m, IsDevice a) => Event -> a -> m ()
- eventSetDeviceTool :: (HasCallStack, MonadIO m, IsDeviceTool a) => Event -> Maybe a -> m ()
- eventSetScreen :: (HasCallStack, MonadIO m, IsScreen a) => Event -> a -> m ()
- eventSetSourceDevice :: (HasCallStack, MonadIO m, IsDevice a) => Event -> a -> m ()
- eventTriggersContextMenu :: (HasCallStack, MonadIO m) => Event -> m Bool
- getEventAny :: MonadIO m => Event -> m EventAny
- getEventButton :: MonadIO m => Event -> m EventButton
- getEventConfigure :: MonadIO m => Event -> m EventConfigure
- getEventCrossing :: MonadIO m => Event -> m EventCrossing
- getEventDnd :: MonadIO m => Event -> m EventDND
- getEventExpose :: MonadIO m => Event -> m EventExpose
- getEventFocusChange :: MonadIO m => Event -> m EventFocus
- getEventGrabBroken :: MonadIO m => Event -> m EventGrabBroken
- getEventKey :: MonadIO m => Event -> m EventKey
- getEventMotion :: MonadIO m => Event -> m EventMotion
- getEventOwnerChange :: MonadIO m => Event -> m EventOwnerChange
- getEventPadAxis :: MonadIO m => Event -> m EventPadAxis
- getEventPadButton :: MonadIO m => Event -> m EventPadButton
- getEventPadGroupMode :: MonadIO m => Event -> m EventPadGroupMode
- getEventProperty :: MonadIO m => Event -> m EventProperty
- getEventProximity :: MonadIO m => Event -> m EventProximity
- getEventScroll :: MonadIO m => Event -> m EventScroll
- getEventSelection :: MonadIO m => Event -> m EventSelection
- getEventSetting :: MonadIO m => Event -> m EventSetting
- getEventTouch :: MonadIO m => Event -> m EventTouch
- getEventTouchpadPinch :: MonadIO m => Event -> m EventTouchpadPinch
- getEventTouchpadSwipe :: MonadIO m => Event -> m EventTouchpadSwipe
- getEventType :: MonadIO m => Event -> m EventType
- setEventType :: MonadIO m => Event -> EventType -> m ()
- getEventVisibility :: MonadIO m => Event -> m EventVisibility
- getEventWindowState :: MonadIO m => Event -> m EventWindowState
Exported types
Memory-managed wrapper type.
Instances
Eq Event Source # | |
GBoxed Event Source # | |
Defined in GI.Gdk.Unions.Event | |
ManagedPtrNewtype Event Source # | |
Defined in GI.Gdk.Unions.Event toManagedPtr :: Event -> ManagedPtr Event | |
TypedObject Event Source # | |
Defined in GI.Gdk.Unions.Event glibType :: IO GType | |
IsGValue Event Source # | Convert |
Defined in GI.Gdk.Unions.Event toGValue :: Event -> IO GValue fromGValue :: GValue -> IO Event | |
HasParentTypes Event Source # | |
Defined in GI.Gdk.Unions.Event | |
tag ~ 'AttrSet => Constructible Event tag Source # | |
type ParentTypes Event Source # | |
Defined in GI.Gdk.Unions.Event type ParentTypes Event = '[] :: [Type] |
Methods
Overloaded methods
copy
free
get
:: (HasCallStack, MonadIO m) | |
=> m (Maybe Event) | Returns: the next |
Checks all open displays for a Event
to process,to be processed
on, fetching events from the windowing system if necessary.
See displayGetEvent
.
getAxis
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> AxisUse |
|
-> m (Bool, Double) | Returns: |
Extract the axis value for a particular axis use from an event structure.
getButton
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m (Bool, Word32) | Returns: |
Extract the button number from an event.
Since: 3.2
getClickCount
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m (Bool, Word32) | Returns: |
Extracts the click count from an event.
Since: 3.2
getCoords
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m (Bool, Double, Double) | Returns: |
Extract the event window relative x/y coordinates from an event.
getDevice
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m (Maybe Device) | Returns: a |
If the event contains a “device” field, this function will return
it, else it will return Nothing
.
Since: 3.0
getDeviceTool
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m DeviceTool | Returns: The current device tool, or |
If the event was generated by a device that supports
different tools (eg. a tablet), this function will
return a DeviceTool
representing the tool that
caused the event. Otherwise, Nothing
will be returned.
Note: the DeviceTool
s will be constant during
the application lifetime, if settings must be stored
persistently across runs, see deviceToolGetSerial
Since: 3.22
getEventSequence
eventGetEventSequence Source #
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m EventSequence | Returns: the event sequence that the event belongs to |
If event
if of type EventTypeTouchBegin
, EventTypeTouchUpdate
,
EventTypeTouchEnd
or EventTypeTouchCancel
, returns the EventSequence
to which the event belongs. Otherwise, return Nothing
.
Since: 3.4
getEventType
Retrieves the type of the event.
Since: 3.10
getKeycode
getKeyval
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m (Bool, Word32) | Returns: |
Extracts the keyval from an event.
Since: 3.2
getPointerEmulated
eventGetPointerEmulated Source #
event
: a Event
Returns whether this event is an 'emulated' pointer event (typically
from a touch event), as opposed to a real one.
Since: 3.22
getRootCoords
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m (Bool, Double, Double) | Returns: |
Extract the root window relative x/y coordinates from an event.
getScancode
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m Int32 | Returns: The associated keyboard scancode or 0 |
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.
Since: 3.22
getScreen
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 which event->motion.x_root
and
event->motion.y_root
are relative.
Since: 2.2
getScrollDeltas
getScrollDirection
eventGetScrollDirection Source #
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m (Bool, ScrollDirection) | Returns: |
Extracts the scroll direction from an event.
If event
is not of type EventTypeScroll
, 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
eventGetScrollDeltas
; for instance:
C code
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; }
Since: 3.2
getSeat
Returns the Seat
this event was generated for.
Since: 3.20
getSourceDevice
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m (Maybe Device) | Returns: a |
This function returns the hardware (slave) Device
that has
triggered the event, falling back to the virtual (master) device
(as in eventGetDevice
) if the event wasn’t caused by
interaction with a hardware device. This may happen for example
in synthesized crossing events after a Window
updates its
geometry or a grab is acquired/released.
If the event does not contain a device field, this function will
return Nothing
.
Since: 3.0
getState
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m (Bool, [ModifierType]) | Returns: |
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. event
may be Nothing
, in which case it’s treated
as if the event had no state field.
getTime
Returns the time stamp from event
, if there is one; otherwise
returns CURRENT_TIME
. If event
is Nothing
, returns CURRENT_TIME
.
getWindow
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m Window | Returns: The |
Extracts the Window
associated with an event.
Since: 3.10
handlerSet
:: (HasCallStack, MonadIO m) | |
=> EventFunc |
|
-> m () |
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+.)
isScrollStopEvent
eventIsScrollStopEvent Source #
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m Bool | Returns: |
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.
Since: 3.20
new
:: (HasCallStack, MonadIO m) | |
=> EventType |
|
-> m Event | Returns: a newly-allocated |
Creates a new event of the given type. All fields are set to 0.
Since: 2.2
peek
:: (HasCallStack, MonadIO m) | |
=> m (Maybe Event) | Returns: a copy of the first |
If there is an event waiting in the event queue of some open
display, returns a copy of it. See displayPeekEvent
.
put
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 Nothing
. See displayPutEvent
.
requestMotions
:: (HasCallStack, MonadIO m) | |
=> EventMotion |
|
-> m () |
Request more motion notifies if event
is a motion notify hint event.
This function should be used instead of windowGetPointer
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 a EventTypeMotionNotify
event usually works like this:
C code
{ // 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 }
Since: 2.12
setDevice
Sets the device for event
to device
. The event must
have been allocated by GTK+, for instance, by
eventCopy
.
Since: 3.0
setDeviceTool
:: (HasCallStack, MonadIO m, IsDeviceTool a) | |
=> Event |
|
-> Maybe a |
|
-> m () |
Sets the device tool for this event, should be rarely used.
Since: 3.22
setScreen
Sets the screen for event
to screen
. The event must
have been allocated by GTK+, for instance, by
eventCopy
.
Since: 2.2
setSourceDevice
Sets the slave device for event
to device
.
The event must have been allocated by GTK+,
for instance by eventCopy
.
Since: 3.0
triggersContextMenu
eventTriggersContextMenu Source #
:: (HasCallStack, MonadIO m) | |
=> Event |
|
-> m Bool | Returns: |
This function returns whether a EventButton
should trigger a
context menu, according to platform conventions. The right mouse
button always triggers context menus. Additionally, if
keymapGetModifierMask
returns a non-0 mask for
ModifierIntentContextMenu
, 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 == BUTTON_SECONDARY
.
Since: 3.4
Properties
any
a EventAny
getEventAny :: MonadIO m => Event -> m EventAny Source #
Get the value of the “any
” field.
When overloading is enabled, this is equivalent to
get
event #any
button
getEventButton :: MonadIO m => Event -> m EventButton Source #
Get the value of the “button
” field.
When overloading is enabled, this is equivalent to
get
event #button
configure
getEventConfigure :: MonadIO m => Event -> m EventConfigure Source #
Get the value of the “configure
” field.
When overloading is enabled, this is equivalent to
get
event #configure
crossing
getEventCrossing :: MonadIO m => Event -> m EventCrossing Source #
Get the value of the “crossing
” field.
When overloading is enabled, this is equivalent to
get
event #crossing
dnd
a EventDND
getEventDnd :: MonadIO m => Event -> m EventDND Source #
Get the value of the “dnd
” field.
When overloading is enabled, this is equivalent to
get
event #dnd
expose
getEventExpose :: MonadIO m => Event -> m EventExpose Source #
Get the value of the “expose
” field.
When overloading is enabled, this is equivalent to
get
event #expose
focusChange
getEventFocusChange :: MonadIO m => Event -> m EventFocus Source #
Get the value of the “focus_change
” field.
When overloading is enabled, this is equivalent to
get
event #focusChange
grabBroken
getEventGrabBroken :: MonadIO m => Event -> m EventGrabBroken Source #
Get the value of the “grab_broken
” field.
When overloading is enabled, this is equivalent to
get
event #grabBroken
key
a EventKey
getEventKey :: MonadIO m => Event -> m EventKey Source #
Get the value of the “key
” field.
When overloading is enabled, this is equivalent to
get
event #key
motion
getEventMotion :: MonadIO m => Event -> m EventMotion Source #
Get the value of the “motion
” field.
When overloading is enabled, this is equivalent to
get
event #motion
ownerChange
getEventOwnerChange :: MonadIO m => Event -> m EventOwnerChange Source #
Get the value of the “owner_change
” field.
When overloading is enabled, this is equivalent to
get
event #ownerChange
padAxis
getEventPadAxis :: MonadIO m => Event -> m EventPadAxis Source #
Get the value of the “pad_axis
” field.
When overloading is enabled, this is equivalent to
get
event #padAxis
padButton
getEventPadButton :: MonadIO m => Event -> m EventPadButton Source #
Get the value of the “pad_button
” field.
When overloading is enabled, this is equivalent to
get
event #padButton
padGroupMode
getEventPadGroupMode :: MonadIO m => Event -> m EventPadGroupMode Source #
Get the value of the “pad_group_mode
” field.
When overloading is enabled, this is equivalent to
get
event #padGroupMode
property
getEventProperty :: MonadIO m => Event -> m EventProperty Source #
Get the value of the “property
” field.
When overloading is enabled, this is equivalent to
get
event #property
proximity
getEventProximity :: MonadIO m => Event -> m EventProximity Source #
Get the value of the “proximity
” field.
When overloading is enabled, this is equivalent to
get
event #proximity
scroll
getEventScroll :: MonadIO m => Event -> m EventScroll Source #
Get the value of the “scroll
” field.
When overloading is enabled, this is equivalent to
get
event #scroll
selection
getEventSelection :: MonadIO m => Event -> m EventSelection Source #
Get the value of the “selection
” field.
When overloading is enabled, this is equivalent to
get
event #selection
setting
getEventSetting :: MonadIO m => Event -> m EventSetting Source #
Get the value of the “setting
” field.
When overloading is enabled, this is equivalent to
get
event #setting
touch
getEventTouch :: MonadIO m => Event -> m EventTouch Source #
Get the value of the “touch
” field.
When overloading is enabled, this is equivalent to
get
event #touch
touchpadPinch
getEventTouchpadPinch :: MonadIO m => Event -> m EventTouchpadPinch Source #
Get the value of the “touchpad_pinch
” field.
When overloading is enabled, this is equivalent to
get
event #touchpadPinch
touchpadSwipe
getEventTouchpadSwipe :: MonadIO m => Event -> m EventTouchpadSwipe Source #
Get the value of the “touchpad_swipe
” field.
When overloading is enabled, this is equivalent to
get
event #touchpadSwipe
type
the EventType
getEventType :: MonadIO m => Event -> m EventType Source #
Get the value of the “type
” field.
When overloading is enabled, this is equivalent to
get
event #type
setEventType :: MonadIO m => Event -> EventType -> m () Source #
Set the value of the “type
” field.
When overloading is enabled, this is equivalent to
set
event [ #type:=
value ]
visibility
getEventVisibility :: MonadIO m => Event -> m EventVisibility Source #
Get the value of the “visibility
” field.
When overloading is enabled, this is equivalent to
get
event #visibility
windowState
getEventWindowState :: MonadIO m => Event -> m EventWindowState Source #
Get the value of the “window_state
” field.
When overloading is enabled, this is equivalent to
get
event #windowState