Skip to content

API Reference / @gtkx/testing / UserEvent

Type Alias: UserEvent ​

UserEvent = object

Defined in: packages/testing/src/user-event/index.ts:21

User interactions exposed by userEvent.

Properties ​

clear ​

clear: (widget, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:47

Deletes all text from an editable widget.

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof clear> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


click ​

click: (widget) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:30

Activates or presses and releases a widget. The click reaches GTK's own pointer handling of a widget only where @gtkx/testing knows its outcome, as for buttons, rows and tabs. A click on a color swatch or a completion proposal does nothing, so press {Space} or {Enter} on a swatch with keyboard, and choose a proposal with the arrow keys and {Enter}. As in Testing Library, a click that nothing handles is not an error.

Parameters ​

widget ​

Gtk.Accessible

Returns ​

Promise<void>


copy ​

copy: (widget, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:52

Copies the current selection.

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof copy> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


cut ​

cut: (widget, ...args) => Promise<void>

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

Cuts the current selection.

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof cut> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


dblClick ​

dblClick: (widget) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:32

Delivers a double-click gesture.

Parameters ​

widget ​

Gtk.Accessible

Returns ​

Promise<void>


deselectOptions ​

deselectOptions: typeof deselectOptions

Defined in: packages/testing/src/user-event/index.ts:77

Unselects positions without activating them. It takes positions as selectOptions does, and a position past the last item or an option label rejects without changing the selection.


drag ​

drag: (widget, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:112

Runs a begin, update, and end sequence on the drag gestures of the widget or its nearest ancestor that has one, ending at the given offset.

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof drag> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


dragAndDrop ​

dragAndDrop: (source, target, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:125

Begins a drag from the drag sources of the source widget or its nearest ancestor that has one, then emits drop with the content on the drop targets of the target widget or its nearest ancestor that has one.

Parameters ​

source ​

Gtk.Accessible

target ​

Gtk.Accessible

args ​

...Parameters<typeof dragAndDrop> extends [Gtk.Widget, Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


drop ​

drop: (widget, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:117

Emits drop with the given content on the drop targets of the widget or its nearest ancestor that has one.

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof drop> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


hover ​

hover: (widget, ...args) => Promise<void>

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

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

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof hover> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


keyboard ​

keyboard: {(input): Promise<void>; (widget, input): Promise<void>; }

Defined in: packages/testing/src/user-event/index.ts:162

Sends a key sequence through GTK's propagation chain. With a widget, the keys go to the focused widget inside it, or to the widget itself. A given widget that can take focus, or passes it to a child as a menu button does to its button, is focused first unless the focus is already inside it, as a user would before typing. Without a widget, the keys go to the focused widget of the active window, as in Testing Library, or to the window itself while its focus widget is not on screen.

Keys go through GTK's key bindings and key controllers, including the ones GTK's own widgets add, so {Space} or {Enter} selects a swatch in a GtkColorChooserWidget. Keys no widget handles reach the window's bindings, so {Tab}, {Shift>}{Tab}{/Shift} and arrow keys move focus. Key controllers the app adds always receive the keys. As in Testing Library, input that nothing handles is not an error.

Some key handlers read the real key event, which keyboard cannot create, so they do not receive the keys:

  • GtkSourceView's own key handling, such as auto-indent and bracket completion. Keys in a GtkSourceView behave as in a plain GtkTextView, except that its completion list takes them while it shows: arrow keys move the selection, {Enter} chooses the selected proposal and {Escape} hides the list.
  • The key capture of a GtkSearchEntry or GtkSearchBar that has a key capture widget.
  • A file chooser's key forwarding.
  • The interactive search of the deprecated GtkTreeView.
  • A WebKit web view.

Call Signature ​

(input): Promise<void>

Parameters ​
input ​

string

Returns ​

Promise<void>

Call Signature ​

(widget, input): Promise<void>

Parameters ​
widget ​

Accessible

input ​

string

Returns ​

Promise<void>


longPress ​

longPress: (widget, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:104

Emits pressed at the given point on the long-press gestures of the widget or its nearest ancestor that has one.

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof longPress> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


paste ​

paste: (widget, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:62

Pastes text or clipboard contents.

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof paste> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


pointer ​

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

Defined in: packages/testing/src/user-event/index.ts:178

Applies a pointer token, such as [MouseLeft] or [MouseRight>], while preserving held-button state. It takes Testing Library's button tokens. [MouseLeft] clicks the widget as click does, and [MouseRight] and [MouseMiddle] press and release the other buttons for the click gestures on the widget and its ancestors that listen for them, so pointer(cell, "[MouseRight]") opens a context menu that a GtkGestureClick with button={Gdk.BUTTON_SECONDARY} shows. A trailing > only presses a button, as in [MouseRight>], and a leading / releases it.

A gesture's handlers read the pressed button with getCurrentButton() and the held modifiers with getCurrentEventState(). No real pointer event exists, so getCurrentEvent() returns null: port upstream code that reads the button from the event, such as event.get_button(), to getCurrentButton().

Parameters ​

widget ​

Gtk.Accessible

input ​

PointerInput

Returns ​

Promise<void>


rotate ​

rotate: (widget, ...args) => Promise<void>

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

Emits angle-changed on the rotate gestures of the widget or its nearest ancestor that has one.

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof rotate> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


scroll ​

scroll: (widget, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:136

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

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof scroll> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


selectOptions ​

selectOptions: typeof selectOptions

Defined in: packages/testing/src/user-event/index.ts:72

Selects positions without activating them. It takes positions rather than option values or labels, because GTK drop-downs, lists and grids have no option values: selectOptions(dropDown, 2) selects the third item, and an array selects several positions in a multiple-selection list. A position past the last item rejects with the range of valid positions, an option label rejects too, and neither changes the selection.


setup ​

setup: (options?) => UserEvent

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

Creates an instance with shared keyboard and pointer state.

Parameters ​

options? ​

UserEventOptions

Returns ​

UserEvent


slide ​

slide: (widget, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:131

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

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof slide> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


swipe ​

swipe: (widget, ...args) => Promise<void>

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

Emits swipe with the given velocity on the swipe gestures of the widget or its nearest ancestor that has one.

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof swipe> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


tab ​

tab: (widget, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:36

Moves focus forward or backward within the root.

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof tab> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


tripleClick ​

tripleClick: (widget) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:34

Delivers a triple-click gesture.

Parameters ​

widget ​

Gtk.Accessible

Returns ​

Promise<void>


type ​

type: (widget, text, options?) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:45

Types into an editable widget, inserting each character as its own edit. Keys named in braces, such as {Enter}, {Backspace} or {Tab}, are pressed as keyboard presses them, and a doubled opening brace types a literal {. Once a key moves focus out of the widget, as {Tab} does, the rest of the text goes to the newly focused widget.

Parameters ​

widget ​

Gtk.Accessible

text ​

string

options? ​

TypeOptions

Returns ​

Promise<void>


unhover ​

unhover: (widget, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:84

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

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof unhover> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>


zoom ​

zoom: (widget, ...args) => Promise<void>

Defined in: packages/testing/src/user-event/index.ts:94

Emits scale-changed on the zoom gestures of the widget or its nearest ancestor that has one.

Parameters ​

widget ​

Gtk.Accessible

args ​

...Parameters<typeof zoom> extends [Gtk.Widget, ...(infer Args)] ? Args : never

Returns ​

Promise<void>