GestureRecognizer class
A helper class that simplifies binding DOM gestures and user interaction events to Jaspr and Naki components.
Converts high-level interaction callbacks (taps, double clicks,
long presses, pointer events, keyboard input, drag & drop, and
focus events) into a clean DOM event listener map compatible with
Jaspr's events attribute.
Basic Usage Example
final gestures = GestureRecognizer(
onClick: (e) => print('Element clicked!'),
onDoubleClick: (e) => print('Element double-clicked!'),
onLongPress: (e) => print('Element long-pressed!'),
);
return NakiGestureDetector(
gestures: gestures,
child: NakiText('Interactive Component'),
);
Input & Keyboard Handling Example
final inputGestures = InputEventRecognizer(
onInput: (e) => print('Input changed'),
onKeyDown: (e) {
if (e.key == 'Enter') print('Enter pressed');
},
onFocus: (e) => print('Field focused'),
onBlur: (e) => print('Field lost focus'),
);
- Implementers
Constructors
- GestureRecognizer({Duration longPressDuration = const Duration(milliseconds: 500), void onClick(Event e)?, void onDoubleClick(MouseEvent e)?, void onLongPress(PointerEvent e)?, void onPointerDown(PointerEvent e)?, void onPointerUp(PointerEvent e)?, void onPointerCancel(PointerEvent e)?, void onPointerEnter(PointerEvent e)?, void onPointerLeave(PointerEvent e)?, void onPointerMove(PointerEvent e)?, void onPointerOver(PointerEvent e)?, void onPointerOut(PointerEvent e)?, void onInput(Event e)?, void onChange(Event e)?, void onMouseDown(MouseEvent e)?, void onMouseUp(MouseEvent e)?, void onMouseEnter(MouseEvent e)?, void onMouseLeave(MouseEvent e)?, void onMouseMove(MouseEvent e)?, void onKeyDown(KeyboardEvent e)?, void onKeyUp(KeyboardEvent e)?, void onDrag(DragEvent e)?, void onDragEnd(DragEvent e)?, void onDragEnter(DragEvent e)?, void onDragLeave(DragEvent e)?, void onDragOver(DragEvent e)?, void onDragStart(DragEvent e)?, void onFocus(FocusEvent e)?, void onFocusIn(FocusEvent e)?, void onFocusOut(FocusEvent e)?, void onBlur(FocusEvent e)?, void onSelect(Event e)?, void onInvalid(Event e)?, void onPaste(ClipboardEvent e)?, void onSubmit(Event e)?})
-
A helper class that simplifies binding DOM gestures and
user interaction events to Jaspr and Naki components.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- longPressDuration → Duration
-
Duration threshold required to trigger onLongPress (default: 500ms).
final
- onBlur → void Function(FocusEvent e)?
-
Callback invoked when the element loses focus.
final
- onChange → void Function(Event e)?
-
Callback invoked when an input element's value
change is committed (e.g. on blur/submit).
final
- onClick → void Function(Event e)?
-
Callback invoked when a standard click gesture occurs.
final
- onDoubleClick → void Function(MouseEvent e)?
-
Callback invoked when a double-click gesture occurs.
final
- onDrag → void Function(DragEvent e)?
-
Callback invoked periodically during an active drag operation.
final
- onDragEnd → void Function(DragEvent e)?
-
Callback invoked when a drag operation completes or is canceled.
final
- onDragEnter → void Function(DragEvent e)?
-
Callback invoked when a dragged item enters the drop target.
final
- onDragLeave → void Function(DragEvent e)?
-
Callback invoked when a dragged item leaves the drop target.
final
- onDragOver → void Function(DragEvent e)?
-
Callback invoked while a dragged item is over the drop target.
final
- onDragStart → void Function(DragEvent e)?
-
Callback invoked when a drag operation is initiated.
final
- onFocus → void Function(FocusEvent e)?
-
Callback invoked when the element gains focus.
final
- onFocusIn → void Function(FocusEvent e)?
-
Callback invoked when focus moves into the element or any descendant.
final
- onFocusOut → void Function(FocusEvent e)?
-
Callback invoked when focus moves out of the element or any descendant.
final
- onInput → void Function(Event e)?
-
Callback invoked when an input element's value
changes synchronously (e.g. while typing).
final
- onInvalid → void Function(Event e)?
-
Callback invoked when the input is invalid.
final
- onKeyDown → void Function(KeyboardEvent e)?
-
Callback invoked when a key is pressed down.
final
- onKeyUp → void Function(KeyboardEvent e)?
-
Callback invoked when a key is released.
final
- onLongPress → void Function(PointerEvent e)?
-
Callback invoked when a pointer is held down for longer
than longPressDuration.
final
- onMouseDown → void Function(MouseEvent e)?
-
Callback invoked when a mouse button is pressed.
final
- onMouseEnter → void Function(MouseEvent e)?
-
Callback invoked when the mouse cursor enters the element.
final
- onMouseLeave → void Function(MouseEvent e)?
-
Callback invoked when the mouse cursor leaves the element.
final
- onMouseMove → void Function(MouseEvent e)?
-
Callback invoked when the mouse cursor moves within the element.
final
- onMouseUp → void Function(MouseEvent e)?
-
Callback invoked when a mouse button is released.
final
- onPaste → void Function(ClipboardEvent e)?
-
Callback invoked when a user pastes data into the element.
final
- onPointerCancel → void Function(PointerEvent e)?
-
Callback invoked when a pointer event is canceled
(e.g. system interrupt).
final
- onPointerDown → void Function(PointerEvent e)?
-
Callback invoked when a pointer device
(mouse, touch, pen) presses down.
final
- onPointerEnter → void Function(PointerEvent e)?
-
Callback invoked when a pointer enters the element boundaries.
final
- onPointerLeave → void Function(PointerEvent e)?
-
Callback invoked when a pointer leaves the element boundaries.
final
- onPointerMove → void Function(PointerEvent e)?
-
Callback invoked when a pointer moves across the element.
final
- onPointerOut → void Function(PointerEvent e)?
-
Callback invoked when a pointer is moved out of the
element or its descendants.
final
- onPointerOver → void Function(PointerEvent e)?
-
Callback invoked when a pointer is moved onto the
element or its descendants.
final
- onPointerUp → void Function(PointerEvent e)?
-
Callback invoked when a pointer device is released.
final
- onSelect → void Function(Event e)?
-
Callback invoked when the user selects some text
(for input/textarea elements).
final
- onSubmit → void Function(Event e)?
-
Callback invoked when the form is submitted.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
toMap
→ Map<
String, void Function(Event)> -
Returns only the active event handlers for non-null callbacks.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited