Class: Touchscreen

Guacamole.Mouse.Touchscreen(elementnon-null)

new Touchscreen(elementnon-null)

Provides cross-browser absolute touch event translation for a given element. Touch events are translated into mouse events as if the touches occurred on a touchscreen (tapping anywhere on the screen clicks at that point, long-press to right-click).
Parameters:
Name Type Description
element Element The Element to use to provide touch events.
Source:
Example
var touchscreen = new Guacamole.Mouse.Touchscreen(client.getDisplay().getElement());

// Emulate a mouse using touchscreen-style gestures, forwarding all mouse
// interaction over Guacamole connection
touchscreen.onEach(['mousedown', 'mousemove', 'mouseup'], function sendMouseEvent(e) {

    // Re-show software mouse cursor if possibly hidden by a prior call to
    // showCursor(), such as a "mouseout" event handler that hides the
    // cursor
    client.getDisplay().showCursor(true);

    client.sendMouseState(e.state, true);

});

Extends

Members

(non-null) clickMoveThreshold :number

The maximum number of pixels to allow a touch to move for the gesture to be considered a click.
Type:
  • number
Source:

(non-null) clickTimingThreshold :number

The maximum number of milliseconds to wait for a touch to end for the gesture to be considered a click.
Type:
  • number
Source:

(non-null) currentState :Guacamole.Mouse.State

The current mouse state. The properties of this state are updated when mouse events fire. This state object is also passed in as a parameter to the handler of any mouse events.
Type:
Inherited From:
Source:

longPressThreshold

The amount of time a press must be held for long press to be detected.
Source:

(non-null) scrollThreshold :number

The distance a two-finger touch must move per scrollwheel event, in pixels.
Type:
  • number
Source:

Methods

click(buttonnon-null, eventsopt)

Clicks (presses and releases) the given mouse button. Valid button names are defined by Guacamole.Mouse.State.Buttons and correspond to the button-related properties of Guacamole.Mouse.State.
Parameters:
Name Type Attributes Default Description
button string The name of the mouse button to click, as defined by Guacamole.Mouse.State.Buttons.
events Event | Array.<Event> <optional>
[] The DOM events related to the click, if any.
Inherited From:
Source:
Fires:

dispatch(eventnon-null)

Dispatches the given event, invoking all event handlers registered with this Guacamole.Event.Target for that event's type.
Parameters:
Name Type Description
event Guacamole.Event The event to dispatch.
Inherited From:
Source:

move(positionnon-null, eventsopt)

Moves the mouse to the given coordinates.
Parameters:
Name Type Attributes Default Description
position Guacamole.Position | object The new coordinates of the mouse pointer. This object may be a Guacamole.Position or any object with "x" and "y" properties.
events Event | Array.<Event> <optional>
[] The DOM events related to the mouse movement, if any.
Inherited From:
Source:
Fires:

off(typenon-null, listenernon-null) → (non-null) {boolean}

Unregisters a listener that was previously registered with on() or onEach(). If no such listener was registered, this function has no effect. If multiple copies of the same listener were registered, the first listener still registered will be removed.
Parameters:
Name Type Description
type string The unique name of the event type handled by the listener being removed.
listener Guacamole.Event.Target~listener The listener function previously provided to on()or onEach().
Inherited From:
Source:
Returns:
true if the specified listener was removed, false otherwise.
Type
boolean

offEach(typesnon-null, listenernon-null) → (non-null) {boolean}

Unregisters listeners that were previously registered with on() or onEach(). If no such listeners were registered, this function has no effect. If multiple copies of the same listener were registered for the same event type, the first listener still registered will be removed.

Invoking this function is equivalent to manually invoking off() for each of the provided types.

Parameters:
Name Type Description
types Array.<string> The unique names of the event types handled by the listeners being removed.
listener Guacamole.Event.Target~listener The listener function previously provided to on() or onEach().
Inherited From:
Source:
Returns:
true if any of the specified listeners were removed, false otherwise.
Type
boolean

on(typenon-null, listenernon-null)

Registers a listener for events having the given type, as dictated by the type property of Guacamole.Event provided to dispatch().
Parameters:
Name Type Description
type string The unique name of this event type.
listener Guacamole.Event.Target~listener The function to invoke when an event having the given type is dispatched. The Guacamole.Event object provided to dispatch() will be passed to this function, along with the dispatching Guacamole.Event.Target.
Inherited From:
Source:

onEach(typesnon-null, listenernon-null)

Registers a listener for events having the given types, as dictated by the type property of Guacamole.Event provided to dispatch().

Invoking this function is equivalent to manually invoking on() for each of the provided types.

Parameters:
Name Type Description
types Array.<string> The unique names of the event types to associate with the given listener.
listener Guacamole.Event.Target~listener The function to invoke when an event having any of the given types is dispatched. The Guacamole.Event object provided to dispatch() will be passed to this function, along with the dispatching Guacamole.Event.Target.
Inherited From:
Source:

out(eventsopt)

Notifies event listeners that the mouse pointer has left the boundaries of the area being monitored for mouse events.
Parameters:
Name Type Attributes Default Description
events Event | Array.<Event> <optional>
[] The DOM events related to the mouse leaving the boundaries of the monitored object, if any.
Inherited From:
Source:
Fires:

press(buttonnon-null, eventsopt)

Presses the given mouse button, if it isn't already pressed. Valid button names are defined by Guacamole.Mouse.State.Buttons and correspond to the button-related properties of Guacamole.Mouse.State.
Parameters:
Name Type Attributes Default Description
button string The name of the mouse button to press, as defined by Guacamole.Mouse.State.Buttons.
events Event | Array.<Event> <optional>
[] The DOM events that are related to the mouse button press, if any.
Inherited From:
Source:
Fires:

release(buttonnon-null, eventsopt)

Releases the given mouse button, if it isn't already released. Valid button names are defined by Guacamole.Mouse.State.Buttons and correspond to the button-related properties of Guacamole.Mouse.State.
Parameters:
Name Type Attributes Default Description
button string The name of the mouse button to release, as defined by Guacamole.Mouse.State.Buttons.
events Event | Array.<Event> <optional>
[] The DOM events related to the mouse button release, if any.
Inherited From:
Source:
Fires:

reset(eventsopt)

Releases all mouse buttons that are currently pressed. If all mouse buttons have already been released, this function has no effect.
Parameters:
Name Type Attributes Default Description
events Event | Array.<Event> <optional>
[] The DOM event related to all mouse buttons being released, if any.
Inherited From:
Source:
Fires:

Events

mousedown

Fired whenever a mouse button is effectively pressed. Depending on the object dispatching the event, this can be due to a true mouse button press (Guacamole.Mouse), an emulated mouse button press from a touch gesture (Guacamole.Mouse.Touchpad and Guacamole.Mouse.Touchscreen), or may be programmatically generated through dispatch(), press(), or click().
Parameters:
Name Type Description
event Guacamole.Mouse.Event The mousedown event that was fired.
Inherited From:
Source:

mousemove

Fired whenever the mouse pointer is effectively moved. Depending on the object dispatching the event, this can be due to true mouse movement (Guacamole.Mouse), emulated mouse movement from a touch gesture (Guacamole.Mouse.Touchpad and Guacamole.Mouse.Touchscreen), or may be programmatically generated through dispatch(), or move().
Parameters:
Name Type Description
event Guacamole.Mouse.Event The mousemove event that was fired.
Inherited From:
Source:

mouseup

Fired whenever a mouse button is effectively released. Depending on the object dispatching the event, this can be due to a true mouse button release (Guacamole.Mouse), an emulated mouse button release from a touch gesture (Guacamole.Mouse.Touchpad and Guacamole.Mouse.Touchscreen), or may be programmatically generated through dispatch(), release(), or click().
Parameters:
Name Type Description
event Guacamole.Mouse.Event The mouseup event that was fired.
Inherited From:
Source: