new Mouse()
A static controller class for managing a simulated mouse.
This class uses a DOM element that looks like a mouse cursor to enhance scripts and assist live demonstrations.
Methods
-
button( [button] [, duration]) <static>
-
Add queued action to highlight a mouse button.
Parameters:
Name Type Argument Description buttonstring | number <optional>
The mouse button to drag, defaults to
LEFT.durationnumber <optional>
The duration to wait after showing in milliseconds, defaults to 0 (no wait).
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
buttonAsync( [button] [, duration]) <async, static>
-
Highlight a mouse button.
Parameters:
Name Type Argument Description buttonstring | number <optional>
The mouse button to drag, defaults to
LEFT.durationnumber <optional>
The duration to wait after showing in milliseconds, defaults to 0 (no wait).
-
callback(callback, args) <static>
-
Add queued action to invoke a callback function.
Parameters:
Name Type Argument Description callbackfunction The function to call in the sequence.
argsany <repeatable>
The arguments associated with the call.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
click( [button] [, duration]) <static>
-
Add queued action to click and releases the simulated mouse arrow in the model.
Parameters:
Name Type Argument Description buttonstring | number <optional>
The mouse button to click, defaults to
LEFT.durationnumber <optional>
The duration of the click in milliseconds, default to cursor default duration.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
clickAndRelease( [button] [, duration]) <static>
-
Add queued action to click the simulated mouse arrow and sends click event to target.
Parameters:
Name Type Argument Description buttonstring | number <optional>
The mouse button to click, defaults to
LEFT.durationnumber <optional>
The duration of the click in milliseconds, default to cursor default duration.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
clickAndReleaseAsync( [button] [, duration]) <static>
-
Click the simulated mouse arrow and sends click event to model canvas.
Parameters:
Name Type Argument Description buttonstring | number <optional>
The mouse button to click, defaults to
LEFT.durationnumber <optional>
The duration of the click in milliseconds, default to cursor default duration.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
clickAsync( [button] [, duration]) <async, static>
-
Click the simulated mouse arrow in the model.
Parameters:
Name Type Argument Description buttonstring | number <optional>
The mouse button to click, defaults to
LEFT.durationnumber <optional>
The duration of the click in milliseconds, default to cursor default duration.
-
clickOn(id [, duration]) <static>
-
Add queued action to move the simulated mouse arrow to the given HTML element id and click it.
Parameters:
Name Type Argument Description idstring The element id of a HTMLElement within the DOM.
durationnumber <optional>
The duration of the move in milliseconds, default to cursor default duration.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
clickOnAsync(id [, duration]) <async, static>
-
Move the simulated mouse arrow to the given HTML element id and click it.
Parameters:
Name Type Argument Description idstring The element id of a HTMLElement in the DOM.
durationnumber <optional>
The duration of the move in milliseconds, default to 600ms.
-
drag(x, y [, button] [, duration]) <static>
-
Add queued action to drag the simulated mouse arrow to the given page coordinates.
Parameters:
Name Type Argument Description xnumber The X-axis page position to drag the mouse to.
ynumber The Y-axis page position to move the mouse to.
buttonstring | number <optional>
The mouse button to drag, defaults to
LEFT.durationnumber <optional>
The duration of the drag in milliseconds, default to cursor default duration.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
dragAsync(x, y [, button] [, duration]) <async, static>
-
Drags the simulated mouse arrow to the given page coordinates.
Parameters:
Name Type Argument Description xnumber The X-axis position to drag the mouse to.
ynumber The Y-axis position to move the mouse to.
buttonstring | number <optional>
The mouse button to drag, defaults to
LEFT.durationnumber <optional>
The duration of the move in milliseconds, default to cursor default.
-
dragToPoint(point [, button] [, duration]) <static>
-
Add queued action to drag the simulated mouse arrow to the given 3D point in the model.
Parameters:
Name Type Argument Description pointTHREE.Vector3 A 3D point in the form {x,y,z}.
buttonstring | number <optional>
The mouse button to drag, defaults to
LEFT.durationnumber <optional>
The duration of the drag in milliseconds, default to cursor default duration.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
dragToPointAsync(point [, button] [, duration]) <async, static>
-
Add queued action to drag the simulated mouse arrow to the given 3D point in the model.
Parameters:
Name Type Argument Description pointTHREE.Vector3 A 3D point in the form {x,y,z}.
buttonstring | number <optional>
The mouse button to drag, defaults to
LEFT.durationnumber <optional>
The duration of the drag in milliseconds, default to cursor default duration.
-
dragToXYZ(x, y, z [, button] [, duration]) <static>
-
Add queued action to drag the simulated mouse arrow to the given 3D model coordinates.
Parameters:
Name Type Argument Description xnumber The X-axis model position to drag the mouse to.
ynumber The Y-axis model position to move the mouse to.
znumber The Z-axis model position to move the mouse to.
buttonstring | number <optional>
The mouse button to drag, defaults to
LEFT.durationnumber <optional>
The duration of the drag in milliseconds, default to cursor default duration.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
dragToXYZAsync(x, y, z [, button] [, duration]) <async, static>
-
Drags the simulated mouse arrow to the given position in the main model canvas.
Parameters:
Name Type Argument Description xnumber | THREE.Vector3 The X-axis position or a 3D model position to move the mouse to.
ynumber | string The Y-axis position to move the mouse to or, if
xis a vector, the button to drag.znumber The z-axis position to move the mouse to or, if
xis a vector, the duration in milliseconds.buttonnumber | string <optional>
The duration of the move in milliseconds, default to 600ms.
durationnumber <optional>
The duration of the move in milliseconds, default to 600ms.
Returns:
Returns the page coordinates of the destination mouse position.
- Type
- THREE.Vector3
-
getElementAtPos( [x] [, y]) <static>
-
Tries to find the DOM element directly underneath the given page coordinates.
If no coordinates are given the current fake mouse position is used.
Parameters:
Name Type Argument Description xnumber <optional>
The X-axis page coordinate, defaults to the fake mouse left position.
ynumber <optional>
The Y-axis page coordinate, defaults to the fake mouse top position.
Returns:
Returns the 2D page coordinates.
- Type
- HTMLElement | null
-
getPos() <static>
-
Retrieves the position of the mouse in 2D page coordinates.
Returns:
Returns the 2D page coordinates.
- Type
- THREE.Vector2
-
getPosAtPoint(point) <static>
-
Compute the 2D page coordinates of a point in the 3D model.
Parameters:
Name Type Description pointTHREE.Vector3 A point within the 3D model.
Returns:
Returns the 2D page coordinates.
- Type
- THREE.Vector2
-
getPosAtXYZ(x, y, z) <static>
-
Compute the 2D page coordinates of the 3D model position.
Parameters:
Name Type Description xnumber The X-axis model position.
ynumber The Y-axis model position.
znumber The Z-axis model position.
Returns:
Returns the 2D page coordinates.
- Type
- THREE.Vector2
-
go() <async, static>
-
Processes any queued simulated mouse action events.
-
hide( [duration]) <static>
-
Add queued action to hide the simulated mouse arrow.
Parameters:
Name Type Argument Description durationnumber <optional>
The duration to wait before hiding in milliseconds, defaults to 0 (no wait).
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
hideAsync( [duration]) <async, static>
-
Hide the simulated mouse arrow.
Parameters:
Name Type Argument Description durationnumber <optional>
The duration to wait before hiding in milliseconds, defaults to 0 (no wait).
-
mouse( [state] [, duration]) <static>
-
Add queued action to show or hide the mouse indicator adjacent to the cursor.
Parameters:
Name Type Argument Description stateboolean <optional>
Whether to show or hide, defaults to true.
durationnumber <optional>
The duration to wait after showing in milliseconds, defaults to 0 (no wait).
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
mouseAsync( [state] [, duration]) <async, static>
-
Show or hide the mouse indicator adjacent to the cursor.
Parameters:
Name Type Argument Description stateboolean <optional>
Whether to show or hide, defaults to true.
durationnumber <optional>
The duration to wait after showing in milliseconds, defaults to 0 (no wait).
-
move(x, y [, duration]) <static>
-
Add queued action to move the simulated mouse arrow to the given page coordinates.
Parameters:
Name Type Argument Description xnumber The X-axis page position to drag the mouse to.
ynumber The Y-axis page position to move the mouse to.
durationnumber <optional>
The duration of the move in milliseconds, default to cursor default duration.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
moveAsync(x, y [, duration]) <async, static>
-
Add queued action to move the simulated mouse arrow to the given page coordinates.
Parameters:
Name Type Argument Description xnumber The X-axis page position to drag the mouse to.
ynumber The Y-axis page position to move the mouse to.
durationnumber <optional>
The duration of the move in milliseconds, default to cursor default duration.
-
moveToCursor( [duration]) <static>
-
Add queued action to move the simulated mouse arrow to the current 3D model cursor position.
This action is most ofter used immediately after dragging the 3D model cursor in order to ensure that a snap value did not move it beyond the range of the simulated mouse arrow.
Parameters:
Name Type Argument Description durationnumber <optional>
The duration of the drag in milliseconds, default to 250ms.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
moveToCursorAsync( [duration]) <async, static>
-
Add queued action to move the simulated mouse arrow to the current 3D model cursor position.
This action is most ofter used immediately after dragging the 3D model cursor in order to ensure that a snap value did not move it beyond the range of the simulated mouse arrow.
Parameters:
Name Type Argument Description durationnumber <optional>
The duration of the drag in milliseconds, default to 250ms.
-
moveToPoint(point [, duration]) <static>
-
Add queued action to move the simulated mouse arrow to the given 3D point in the model.
Parameters:
Name Type Argument Description pointTHREE.Vector3 A 3D point in the form {x,y,z}.
durationnumber <optional>
The duration of the drag in milliseconds, default to cursor default duration.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
moveToPointAsync(point [, duration]) <async, static>
-
Move the simulated mouse arrow to the given 3D point in the model.
Parameters:
Name Type Argument Description pointTHREE.Vector3 A 3D point in the form {x,y,z}.
durationnumber <optional>
The duration of the drag in milliseconds, default to cursor default duration.
-
moveToXYZ(x, y, z [, duration]) <static>
-
Add queued action to move the simulated mouse arrow to the given 3D model coordinates.
Parameters:
Name Type Argument Description xnumber The X-axis model position to drag the mouse to.
ynumber The Y-axis model position to move the mouse to.
znumber The Z-axis model position to move the mouse to.
durationnumber <optional>
The duration of the move in milliseconds, default to cursor default duration.
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
moveToXYZAsync(x, y, z [, duration]) <async, static>
-
Moves the simulated mouse arrow to the given position in the main model canvas.
Parameters:
Name Type Argument Description xnumber | THREE.Vector3 The X-axis position or a 3D model position to move the mouse to.
ynumber The Y-axis position to move the mouse to or, if
xis a vector, the duration in milliseconds.znumber The Z-axis position to move the mouse to.
durationnumber <optional>
The duration of the move in milliseconds, default to 600ms.
Returns:
Returns the page coordinates of the destination mouse position.
- Type
- THREE.Vector3
-
setSimulatedArrow(cursor) <static>
-
Set the simulated mouse arrow controller to use.
Parameters:
Name Type Description cursorobject The simulated mouse arrow controller with an
action()method. -
show( [duration]) <static>
-
Add queued action to display the simulated mouse arrow.
Parameters:
Name Type Argument Description durationnumber <optional>
The duration to wait after showing in milliseconds, defaults to 0 (no wait).
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
showAsync( [duration]) <async, static>
-
Displays the simulated mouse arrow.
Parameters:
Name Type Argument Description durationnumber <optional>
The duration to wait after showing in milliseconds, defaults to 0 (no wait).
-
text(message [, duration]) <static>
-
Add queued action to display the given message beneath the simulated mouse arrow.
Parameters:
Name Type Argument Description messagestring The message tp display beneath the cursor.
durationnumber <optional>
The duration to wait after showing in milliseconds, defaults to 0 (no wait).
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
textAsync(message [, duration]) <async, static>
-
Add queued action to display the given message beneath the simulated mouse arrow.
Parameters:
Name Type Argument Description messagestring The message tp display beneath the cursor.
durationnumber <optional>
The duration to wait after showing in milliseconds, defaults to 0 (no wait).
-
wait( [duration]) <static>
-
Add queued action to wait for the given duration.
Parameters:
Name Type Argument Description durationnumber <optional>
The duration to wait after showing in milliseconds, defaults to 0 (no wait).
Returns:
Returns this mouse instance to support method chaining.
- Type
- PD.Mouse
-
waitAsync( [duration]) <async, static>
-
Wait for the given duration.
Parameters:
Name Type Argument Description durationnumber <optional>
The duration to wait after showing in milliseconds, defaults to 0 (no wait).