### ----------------------------------------------------
### -- Gnome::Gtk3
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: docs/content-docs/reference/Gdk3/Events.md
### ----------------------------------------------------
### -- Chunk 2 of 2
new
---

### :type

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

Returns: a newly-allocated **Gnome::Gdk3::Event**. This object should be freed with `clear-object()`.

    multi method new ( GdkEventType :$type! )

  * $type; a **Gnome::Gdk3::EventType**

### :get

When `:get` is given (no value needed) it checks all open displays for a an event to process, to be processed on, fetching events from the windowing system if necessary. See `Gnome::Gdk3::Display.get-event()`.

Gets the next **Gnome::Gdk3::Event** to be processed, or, if no events are pending, the object becomes invalid. As always, this object should be freed with `clear-object()`.

    multi method get ( :get! )

### :native-object

    multi method new ( Gnome::GObject::Object :$native-object! )

Create an object using a native object from elsewhere. See also `Gnome::GObject::Object`.

get-angle
---------

If this and the provided event contain X/Y information, this function will return a defined angle, the relative angle from this event to *$event*. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.

    method get-angle ( N-GdkEvent $event --> Num )

  * $event; the second **Gnome::Gdk3::Event**

get-center
----------

If this and the provided event contain X/Y information, the center of both coordinates will be returned in a List. An empty list is returned otherwise.

    method get-center ( N-GdkEvent $event2 --> List )

  * $event; the second **Gnome::Gdk3::Event**

List returns

  * Num; the X coordinate of the center

  * Num; the Y coordinate of the center

get-axis
--------

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

Returns: the axis value if the specified axis was found, otherwise an undefined `Num`.

    method get-axis ( GdkAxisUse $axis_use --> Num )

  * $axis_use; the axis use to look for

get-button
----------

Extract the button number from an event.

Returns: a defined `Int` if the event delivered a button number.

    method get-button ( --> Int )

get-click-count
---------------

Extracts the click count from an event.

Returns: a defined `Int` if the event delivered a click count

    method get-click-count ( --> Int )

get-coords
----------

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

Returns: `True` if the event delivered event window coordinates

    method get-coords ( --> List )

List returns;

  * Num; event window x coordinate

  * Num; event window y coordinate

get-device
----------

If the event contains a “device” field, this function will return it, else it will return `undefined` or an invalid object in the case of `get-device-rk()`.

Returns: a **Gnome::Gdk3::Device**, or `undefined`.

    method get-device ( --> N-GObject )

get-distance
------------

If this and the provided event have X/Y information, the distance between both coordinates (as in a straight line going from this event to *$event*) will be returned. Otherwise returned value is undefined.

    method get-distance ( N-GdkEvent $event --> Num )

  * $event; second **Gnome::Gdk3::Event**

get-event-type
--------------

Retrieves the type of the event.

Returns: a **Gnome::Gdk3::EventType**

    method get-event-type ( --> GdkEventType )

get-keycode
-----------

Extracts the hardware keycode from an event.

Also see `get-scancode()`.

Returns: a defined keycode if the event delivered a hardware keycode, undefined otherwise.

    method get-keycode ( --> UInt )

get-keyval
----------

Extracts the keyval from an event.

Returns: a defined key symbol if the event delivered a key symbol, undefined otherwise.

    method get-keyval ( --> UInt )

get-pointer-emulated
--------------------

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

    method get-pointer-emulated ( --> Bool )

get-root-coords
---------------

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

Returns: a list if the event delivered root window coordinates. The list is empty if not.

    method get-root-coords ( --> List )

The List returns

  * Num; root window x coordinate

  * Num; root window y coordinate

get-scancode
------------

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.

Returns: The associated keyboard scancode or 0

    method get-scancode ( --> Int )

get-screen
----------

Returns the screen for the event. The screen is typically the screen in any `$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.

Returns: the screen for the event

    method get-screen ( --> N-GObject )

  * $event; a **Gnome::Gdk3::Event**

get-scroll-deltas
-----------------

Retrieves the scroll deltas from this event

See also: `gdk_event_get_scroll_direction()`

Returns: A List holding the values if the event contains smooth scroll information and an empty List otherwise.

    method get-scroll-deltas ( --> List )

The List returns;

  * Num; X delta

  * Num; Y delta

get-scroll-direction
--------------------

Extracts the scroll direction from an event.

If *event* is not of type `GDK_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 `get-scroll-deltas()`; for instance:

    # Handle discrete scrolling with a known constant delta;
    constant Num $delta = 12e0;

    my GdkScrollDirection $direction;
    my Num $vscroll_factor = 0e0;
    my Num ( $x_scroll, $y_scroll);

    if ?( $direction = $event.get-scroll-direction ) {
      with $direction {
        when GDK_SCROLL_UP {
          $vscroll_factor = -$delta;
        }

        when GDK_SCROLL_DOWN {
          $vscroll_factor = $delta;
        }

        default {
          # no scrolling
        }
      }
    }

    elsif my List $deltas = $event.get-scroll-deltas {
      # Handle smooth scrolling directly
      $vscroll_factor = $deltas[1];
    }

Returns: a defined GdkScrollDirection value if the event delivered a scroll direction and undefined otherwise

    method get-scroll-direction ( --> GdkScrollDirection )

get-show-events
---------------

Gets whether event debugging output is enabled.

Returns: `True` if event debugging output is enabled.

    method get-show-events ( --> Bool )

get-source-device
-----------------

This function returns the hardware secondary **Gnome::Gdk3::Device** that has triggered the event, falling back to the virtual primary device (as in `get-device()`) if the event wasn’t caused by interaction with a hardware device.

This may happen for example in synthesized crossing events after a **Gnome::Gdk3::Window** updates its geometry or a grab is acquired/released.

If the event does not contain a device field, this function will return `undefined` or an invalid object in the case of `get-source-device-rk()`.

Returns: a **Gnome::Gdk3::Device**, or `undefined`.

    method get-source-device ( --> N-GObject )

  * $event; a **Gnome::Gdk3::Event**

get-state
---------

If the event contains a “state” field, returns that field.

Returns a defined state value if there was a state field in the event. Undefined otherwise.

    method get-state ( --> GdkModifierType )

get-time
--------

Returns the time stamp from *event*, if there is one; otherwise returns the current time.

Returns: time stamp field from this event

    method get-time ( --> UInt )

get-window
----------

Extracts the **Gnome::Gdk3::Window** associated with an event.

    method get-window ( --> N-GObject )

is-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 delta of 0/0.

    method is-scroll-stop-event ( --> Bool )

pending
-------

Checks if any events are ready to be processed for any display.

Returns: `True` if any events are pending.

    method pending ( --> Bool )

put
---

Appends a copy of this event onto the front of the event queue for `$event.any.window`’s display, or the default event queue if `$event.any.window` is `undefined`. See `Gnome::Gdk3::Display.put-event()`.

    method put ( )

request-motions
---------------

Request more motion notifies if this event is a motion notify hint event.

This function should be used instead of `Gnome::Gdk3::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 a `GDK_MOTION_NOTIFY` event usually works like this:

    method request-motions ( )

set-device
----------

Sets the device for *event* to *device*. The event must have been allocated by GTK+, for instance, by `copy()`.

    method set-device ( N-GObject $device )

  * $device; a **Gnome::Gdk3::Device**

set-screen
----------

Sets the screen for *event* to *screen*. The event must have been allocated by GTK+, for instance, by `gdk_event_copy()`.

    method set-screen ( N-GObject $screen )

  * $screen; a **Gnome::Gdk3::Screen**

set-show-events
---------------

Sets whether a trace of received events is output. Note that GTK+ must be compiled with debugging (that is, configured using the `--enable-debug` option) to use this option.

    method set-show-events ( Bool $show_events )

  * $show_events; `True` to output event debugging information.

set-source-device
-----------------

Sets the slave device for *event* to *device*.

The event must have been allocated by GTK+, for instance by `gdk_event_copy()`.

    method set-source-device ( N-GObject $device )

  * $device; a **Gnome::Gdk3::Device**

triggers-context-menu
---------------------

This function returns whether this event (a GdkEventButton type) should trigger a context menu, according to platform conventions. The right mouse button always triggers context menus. Additionally, if `gdk_keymap_get_modifier_mask()` returns a non-0 mask for `GDK_MODIFIER_INTENT_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`.

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

    method triggers-context-menu ( --> Bool )



