Skip to content

API Reference / @gtkx/testing / UserEvent

Type Alias: UserEvent ​

UserEvent = object

Defined in: packages/testing/dist/user-event/index.d.ts:18

The set of user interaction helpers exposed by userEvent, covering clicks, typing, keyboard, pointer, gestures, selection, and scrolling.

Properties ​

clear ​

clear: typeof clear

Defined in: packages/testing/dist/user-event/index.d.ts:65

Focuses an editable widget and deletes its whole text, leaving nothing selected.


click ​

click: typeof click

Defined in: packages/testing/dist/user-event/index.d.ts:40

Activates a widget that neither claims the click nor carries a click gesture of its own, and otherwise presses and releases outwards from the clicked widget through every widget carrying a click gesture, stopping at the first button or indexed child. A list box row or flow box child receives its click gesture at the clicked position, passes one on to the gestures its container carries, and is then activated, or exclusively selected when its container does not activate on a single click. The press also stops at a widget whose click GTK4 implements itself, where the gestures that widget carries of its own still take the press and the same outcome is then applied through GTK's own public action: a list, grid, or column-view row is focused and selected, and activated as well when its view activates on a single click; an expandable tree expander that is itself the clicked widget toggles its expansion; a notebook tab, clicked directly or through its label, focuses its notebook and switches to its page; a column header sorts by its column. A column-view cell and the row carrying the column headers stand in the way of the click rather than taking it, so a click on either reaches the row or the view behind it.


copy ​

copy: typeof copy

Defined in: packages/testing/dist/user-event/index.d.ts:67

Writes an editable widget's current selection to the clipboard.


cut ​

cut: typeof cut

Defined in: packages/testing/dist/user-event/index.d.ts:69

Writes an editable widget's current selection to the clipboard and deletes it.


dblClick ​

dblClick: typeof dblClick

Defined in: packages/testing/dist/user-event/index.d.ts:49

Delivers a two-press click gesture along the same path a single click takes, without trying activation first, activating a list box row or flow box child on that path and replacing its container's selection whether or not that container activates on a single click. A widget whose click GTK4 implements itself receives that outcome once per press, so a row is selected and activated by the second press, a tree expander ends back where it started, a notebook tab stays on the page the first press opened, and a column header inverts its order after sorting.


deselectOptions ​

deselectOptions: typeof deselectOptions

Defined in: packages/testing/dist/user-event/index.d.ts:81

Unselects the items at those positions, leaving list box and flow box children unactivated.


drag ​

drag: typeof drag

Defined in: packages/testing/dist/user-event/index.d.ts:95

Runs a begin, update, and end sequence on the widget's drag gestures, ending at the given offset.


dragAndDrop ​

dragAndDrop: typeof dragAndDrop

Defined in: packages/testing/dist/user-event/index.d.ts:99

Requires a drag source on the source widget, then emits drop with the content on the target's drop targets.


drop ​

drop: typeof drop

Defined in: packages/testing/dist/user-event/index.d.ts:97

Emits drop with the given content on the widget's drop targets.


hover ​

hover: typeof hover

Defined in: packages/testing/dist/user-event/index.d.ts:83

Emits a motion enter on the widget, adding a motion controller when it has none.


keyboard ​

keyboard: (widget, input) => Promise<void>

Defined in: packages/testing/dist/user-event/index.d.ts:123

Sends a key sequence along the chain GTK4 propagates a key event through: the application's accelerators first, then the capture-phase controllers from the root down to the event widget, the event widget's target-phase controllers, and the bubble-phase controllers from it back up to the root, so a key controller or shortcut controller a container or window above the widget carries receives the key too, each in the phase it declares. The event widget is the editable delegate GTK4 focuses when the widget has one, the Gtk.Text inside a Gtk.Entry for instance, so the delegate stands ahead of the widget in the chain. A shortcut controller whose scope is not local runs where it registered instead, the root for a global one and the nearest Gtk.ShortcutManager for a managed one, so it fires wherever focus sits inside that subtree and never at its own widget, while a shortcut whose widget is insensitive or unmapped stays inert wherever it sits. The first controller that handles a press ends the chain, and a Gdk.KEY_Return press none of them handled reaches an editable widget's activate handler. Built-in key bindings take part, since GTK4 carries them on a shortcut controller: a Gtk.Text's arrow keys or a Gtk.TextView's undo can consume a press before an ancestor sees it. Key controllers GTK4 attaches itself are the exception, since they read a GDK event that off-screen synthesis cannot produce, so only the key controllers the tree connected a key-pressed or key-released handler to take part. Held modifiers carry across calls.

Parameters ​

widget ​

Gtk.Widget

input ​

string

Returns ​

Promise<void>


longPress ​

longPress: typeof longPress

Defined in: packages/testing/dist/user-event/index.d.ts:93

Emits pressed at the given point on the widget's long-press gestures.


paste ​

paste: typeof paste

Defined in: packages/testing/dist/user-event/index.d.ts:74

Inserts the given text, or the clipboard's text, at an editable widget's cursor, deleting the text the widget has selected first, the way GTK4 does.


pointer ​

pointer: (widget, input) => Promise<void>

Defined in: packages/testing/dist/user-event/index.d.ts:130

Applies a pointer token to the click gestures the widget already carries, tracking whether the left button is held across calls. On a widget whose click GTK4 implements itself, the release also applies GTK's own outcome, the way UserEvent.click does, and a column-view cell or the row carrying the column headers passes the token to the row or view behind it.

Parameters ​

widget ​

Gtk.Widget

input ​

PointerInput

Returns ​

Promise<void>


rotate ​

rotate: typeof rotate

Defined in: packages/testing/dist/user-event/index.d.ts:87

Emits angle-changed on the widget's rotate gestures.


scroll ​

scroll: typeof scroll

Defined in: packages/testing/dist/user-event/index.d.ts:103

Adds the delta to the adjustments of the widget itself, or of its nearest scrollable ancestor.


selectOptions ​

selectOptions: typeof selectOptions

Defined in: packages/testing/dist/user-event/index.d.ts:79

Selects the items at those positions in a view or drop-down, or selects the indexed children of a list box or flow box through their container, without activating them.


setup ​

setup: (options?) => UserEvent

Defined in: packages/testing/dist/user-event/index.d.ts:23

Returns a fresh instance whose helpers share one keyboard and pointer state, so held modifiers and buttons carry across its calls but not across instances.

Parameters ​

options? ​

UserEventOptions

Returns ​

UserEvent


slide ​

slide: typeof slide

Defined in: packages/testing/dist/user-event/index.d.ts:101

Emits a jump change-value on a Gtk.Range so it moves to the given value.


swipe ​

swipe: typeof swipe

Defined in: packages/testing/dist/user-event/index.d.ts:91

Emits swipe with the given velocity on the widget's swipe gestures.


tab ​

tab: typeof tab

Defined in: packages/testing/dist/user-event/index.d.ts:57

Moves focus within the widget's root, forward by default and backward with isShiftHeld.


tripleClick ​

tripleClick: typeof tripleClick

Defined in: packages/testing/dist/user-event/index.d.ts:55

Delivers a three-press click gesture the same way a double click is delivered, applying the same outcome to a list box row or flow box child, and applying the outcome GTK4 implements itself once per press to a row, tree expander, notebook tab, or column header.


type ​

type: typeof type

Defined in: packages/testing/dist/user-event/index.d.ts:63

Focuses an editable widget the way clicking into it does, leaving its text unselected, applies any initial selection, and inserts the text at the cursor, deleting the text the widget has selected first, the way GTK4 does.


unhover ​

unhover: typeof unhover

Defined in: packages/testing/dist/user-event/index.d.ts:85

Emits a motion leave on the widget, adding a motion controller when it has none.


zoom ​

zoom: typeof zoom

Defined in: packages/testing/dist/user-event/index.d.ts:89

Emits scale-changed on the widget's zoom gestures.