new Mouse(elementnon-null)
Provides cross-browser mouse events for a given element. The events of
the given element are automatically populated with handlers that translate
mouse events into a non-browser-specific event provided by the
Guacamole.Mouse instance.
Parameters:
Name | Type | Description |
---|---|---|
element |
Element | The Element to use to provide mouse events. |
- Source:
Examples
var mouse = new Guacamole.Mouse(client.getDisplay().getElement());
// Forward all mouse interaction over Guacamole connection
mouse.onEach(['mousedown', 'mousemove', 'mouseup'], function sendMouseEvent(e) {
client.sendMouseState(e.state, true);
});
// Hide software cursor when mouse leaves display
mouse.on('mouseout', function hideCursor() {
client.getDisplay().showCursor(false);
});
Extends
Classes
Members
(non-null) PIXELS_PER_LINE :number
The number of pixels to scroll per line.
Type:
- number
- Source:
(non-null) PIXELS_PER_PAGE :number
The number of pixels to scroll per page.
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:
(non-null) scrollThreshold :number
The minimum amount of pixels scrolled required for a single scroll button
click.
Type:
- number
- Source:
(non-null) touchMouseThreshold :number
The number of mousemove events to require before re-enabling mouse
event handling after receiving a touch event.
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:
setCursor(canvasnon-null, xnon-null, ynon-null) → (non-null) {boolean}
Changes the local mouse cursor to the given canvas, having the given
hotspot coordinates. This affects styling of the element backing this
Guacamole.Mouse only, and may fail depending on browser support for
setting the mouse cursor.
If setting the local cursor is desired, it is up to the implementation
to do something else, such as use the software cursor built into
Guacamole.Display, if the local cursor cannot be set.
Parameters:
Name | Type | Description |
---|---|---|
canvas |
HTMLCanvasElement | The cursor image. |
x |
number | The X-coordinate of the cursor hotspot. |
y |
number | The Y-coordinate of the cursor hotspot. |
- Source:
Returns:
true if the cursor was successfully set, false if the cursor could
not be set for any reason.
- Type
- boolean
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:
mouseout
Fired whenever the mouse pointer leaves the boundaries of the element
being monitored for interaction. This will only ever be automatically
fired due to movement of an actual mouse device via
Guacamole.Mouse unless programmatically generated through
dispatch(),
or out().
Parameters:
Name | Type | Description |
---|---|---|
event |
Guacamole.Mouse.Event | The mouseout 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: