Class pwlib.extensions.mousekeys
The MouseKeys extension.
Defined in: mousekeys.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Field Attributes | Field Name and Description |
---|---|
<private> <inner> |
Holds the current mouse movement acceleration, taken from the
configuration.
|
<private> <inner> |
Holds a reference to the DOM element representing the pointer on top of the
canvas element.
|
<private> <inner> |
Holds the current mouse movement speed in pixels.
|
Method Attributes | Method Name and Description |
---|---|
The
extensionRegister event handler. |
|
The
extensionUnregister event handler. |
|
keydown(ev)
The
keydown event handler. |
|
keypress(ev)
The
keypress event handler. |
|
keyup(ev)
The
keyup event handler. |
|
<inner> |
pointerMousemove(ev)
Track the virtual pointer coordinates, by updating the position of the
pointer element.
|
- Parameters:
- {PaintWeb} app
- Reference to the main paint application object.
- See:
- PaintWeb.config.mousekeys.accel The mouse keys acceleration setting.
extensionRegister
event handler. This initializes the
extension by adding the pointer DOM element and by setting up the keyboard
shortcuts.
- Returns:
- {Boolean} True if the extension initialized successfully, or false if not.
extensionUnregister
event handler. This will remove the
pointer DOM element and the canvas event listener.
keydown
event handler.
This method requires a DOM Event object which has the ev.kobj_ object reference from the keyboard shortcuts configuration. The kobj_ object must have the action property. Support for the "ButtonToggle" and the "ButtonClick" actions is implemented.
The "ButtonToggle" action essentially means that a mouse event will be
generated, either mousedown
or mouseup
. By
alternating these two events, this method allows the user to start and stop
the drawing operation at any moment using the keyboard shortcut they have
configured.
Under typical usage, the "ButtonClick" action translates the
keydown
event to mousedown
. The
keyup
event handler will also fire the mouseup
event. This allows the user to simulate holding down the mouse button,
while he/she holds down a key.
A click
event is always fired after the firing of
a mouseup
event.
Irrespective of the key the user pressed, this method does always reset the speed and acceleration of the pointer movement.
- Parameters:
- {Event} ev
- The DOM Event object.
- Returns:
- {Boolean} True if the keyboard shortcut was recognized, or false if not.
- See:
- PaintWeb.config.mousekeys.actions The keyboard shortcuts configuration object.
keypress
event handler.
This method requires a DOM Event object with a ev.kobj_ object reference to the keyboard shortcut configuration. The keyboard shortcut configuration object must have the action property.
This event handler implements support for the following param values: "SouthWest", "South", "SouthEast", "West", "East", "NorthWest", "North" and "NorthEast", All of these values indicate the movement direction. This method generates synthetic movemove events based on the direction desired, effectively emulating the use of a real pointing device.
- Parameters:
- {Event} ev
- The DOM Event object.
- Returns:
- {Boolean} True if the keyboard shortcut was recognized, or false if not.
- See:
- PaintWeb.config.mousekeys.actions The keyboard shortcuts configuration object.
keyup
event handler.
This method requires a DOM Event object which has the ev.kobj_ object reference from the keyboard shortcuts configuration. The kobj_ object must have the action property. Support for the "ButtonClick" action is implemented.
Under typical usage, the "ButtonClick" action translates the
keydown
event to mousedown
. This event handler
fires the mouseup
event. This allows the user to simulate
holding down the mouse button, while he/she holds down a key.
A click
event is always fired after the firing of the
mouseup
event.
- Parameters:
- {Event} ev
- The DOM Event object.
- Returns:
- {Boolean} True if the keyboard shortcut was recognized, or false if not.
- See:
- PaintWeb.config.mousekeys.actions The keyboard shortcuts configuration object.
- Parameters:
- {Event} ev
- The DOM Event object.