gi-gdk-3.0.23: Gdk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gdk.Unions.Event

Description

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

Exported types

newtype Event Source #

Memory-managed wrapper type.

Constructors

Event (ManagedPtr Event) 

Instances

Instances details
Eq Event Source # 
Instance details

Defined in GI.Gdk.Unions.Event

Methods

(==) :: Event -> Event -> Bool

(/=) :: Event -> Event -> Bool

GBoxed Event Source # 
Instance details

Defined in GI.Gdk.Unions.Event

ManagedPtrNewtype Event Source # 
Instance details

Defined in GI.Gdk.Unions.Event

Methods

toManagedPtr :: Event -> ManagedPtr Event

TypedObject Event Source # 
Instance details

Defined in GI.Gdk.Unions.Event

Methods

glibType :: IO GType

IsGValue Event Source #

Convert Event to and from GValue with toGValue and fromGValue.

Instance details

Defined in GI.Gdk.Unions.Event

Methods

toGValue :: Event -> IO GValue

fromGValue :: GValue -> IO Event

HasParentTypes Event Source # 
Instance details

Defined in GI.Gdk.Unions.Event

tag ~ 'AttrSet => Constructible Event tag Source # 
Instance details

Defined in GI.Gdk.Unions.Event

Methods

new :: MonadIO m => (ManagedPtr Event -> Event) -> [AttrOp Event tag] -> m Event

type ParentTypes Event Source # 
Instance details

Defined in GI.Gdk.Unions.Event

type ParentTypes Event = '[] :: [Type]

newZeroEvent :: MonadIO m => m Event Source #

Construct a Event struct initialized to zero.

Methods

Overloaded methods

copy

eventCopy Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m Event

Returns: a copy of event. The returned Event should be freed with eventFree.

Copies a Event, copying or incrementing the reference count of the resources associated with it (e.g. Window’s and strings).

free

eventFree Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event.

-> m () 

Frees a Event, freeing or decrementing any resources associated with it. Note that this function should only be called with events returned from functions such as eventPeek, eventGet, eventCopy and eventNew.

get

eventGet Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m (Maybe Event)

Returns: the next Event to be processed, or Nothing if no events are pending. The returned Event should be freed with eventFree.

Checks all open displays for a Event to process,to be processed on, fetching events from the windowing system if necessary. See displayGetEvent.

getAxis

eventGetAxis Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> AxisUse

axisUse: the axis use to look for

-> m (Bool, Double)

Returns: True if the specified axis was found, otherwise False

Extract the axis value for a particular axis use from an event structure.

getButton

eventGetButton Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m (Bool, Word32)

Returns: True if the event delivered a button number

Extract the button number from an event.

Since: 3.2

getClickCount

eventGetClickCount Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m (Bool, Word32)

Returns: True if the event delivered a click count

Extracts the click count from an event.

Since: 3.2

getCoords

eventGetCoords Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m (Bool, Double, Double)

Returns: True if the event delivered event window coordinates

Extract the event window relative x/y coordinates from an event.

getDevice

eventGetDevice Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event.

-> m (Maybe Device)

Returns: a Device, or Nothing.

If the event contains a “device” field, this function will return it, else it will return Nothing.

Since: 3.0

getDeviceTool

eventGetDeviceTool Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m DeviceTool

Returns: The current device tool, or Nothing

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 DeviceTools will be constant during the application lifetime, if settings must be stored persistently across runs, see deviceToolGetSerial

Since: 3.22

getEventSequence

eventGetEventSequence Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a 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

eventGetEventType Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m EventType

Returns: a EventType

Retrieves the type of the event.

Since: 3.10

getKeycode

eventGetKeycode Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m (Bool, Word16)

Returns: True if the event delivered a hardware keycode

Extracts the hardware keycode from an event.

Also see eventGetScancode.

Since: 3.2

getKeyval

eventGetKeyval Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m (Bool, Word32)

Returns: True if the event delivered a key symbol

Extracts the keyval from an event.

Since: 3.2

getPointerEmulated

eventGetPointerEmulated Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event 
-> m Bool

Returns: True if this event is emulated

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

eventGetRootCoords Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m (Bool, Double, Double)

Returns: True if the event delivered root window coordinates

Extract the root window relative x/y coordinates from an event.

getScancode

eventGetScancode Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a 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

eventGetScreen Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m Screen

Returns: the screen for the event

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

eventGetScrollDeltas Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m (Bool, Double, Double)

Returns: True if the event contains smooth scroll information and False otherwise

Retrieves the scroll deltas from a Event

See also: eventGetScrollDirection

Since: 3.4

getScrollDirection

eventGetScrollDirection Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m (Bool, ScrollDirection)

Returns: True if the event delivered a scroll direction and False otherwise

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

eventGetSeat Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m Seat

Returns: The Seat of this event

Returns the Seat this event was generated for.

Since: 3.20

getSourceDevice

eventGetSourceDevice Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m (Maybe Device)

Returns: a Device, or Nothing.

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

eventGetState Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event or Nothing

-> m (Bool, [ModifierType])

Returns: True if there was a state field in the event

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

eventGetTime Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m Word32

Returns: time stamp field from event

Returns the time stamp from event, if there is one; otherwise returns CURRENT_TIME. If event is Nothing, returns CURRENT_TIME.

getWindow

eventGetWindow Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m Window

Returns: The Window associated with the event

Extracts the Window associated with an event.

Since: 3.10

handlerSet

eventHandlerSet Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> EventFunc

func: the function to call to handle events from GDK.

-> 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 #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event

-> m Bool

Returns: True if the event is a scroll stop event

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

eventNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> EventType

type: a EventType

-> m Event

Returns: a newly-allocated Event. The returned Event should be freed with eventFree.

Creates a new event of the given type. All fields are set to 0.

Since: 2.2

peek

eventPeek Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m (Maybe Event)

Returns: a copy of the first Event on some event queue, or Nothing if no events are in any queues. The returned Event should be freed with eventFree.

If there is an event waiting in the event queue of some open display, returns a copy of it. See displayPeekEvent.

put

eventPut Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event.

-> m () 

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

eventRequestMotions Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> EventMotion

event: a valid Event

-> 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

eventSetDevice Source #

Arguments

:: (HasCallStack, MonadIO m, IsDevice a) 
=> Event

event: a Event

-> a

device: a Device

-> m () 

Sets the device for event to device. The event must have been allocated by GTK+, for instance, by eventCopy.

Since: 3.0

setDeviceTool

eventSetDeviceTool Source #

Arguments

:: (HasCallStack, MonadIO m, IsDeviceTool a) 
=> Event

event: a Event

-> Maybe a

tool: tool to set on the event, or Nothing

-> m () 

Sets the device tool for this event, should be rarely used.

Since: 3.22

setScreen

eventSetScreen Source #

Arguments

:: (HasCallStack, MonadIO m, IsScreen a) 
=> Event

event: a Event

-> a

screen: a Screen

-> m () 

Sets the screen for event to screen. The event must have been allocated by GTK+, for instance, by eventCopy.

Since: 2.2

setSourceDevice

eventSetSourceDevice Source #

Arguments

:: (HasCallStack, MonadIO m, IsDevice a) 
=> Event

event: a Event

-> a

device: a Device

-> m () 

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 #

Arguments

:: (HasCallStack, MonadIO m) 
=> Event

event: a Event, currently only button events are meaningful values

-> m Bool

Returns: True if the event should trigger a context menu.

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

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

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

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

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