Skip to content

Latest commit

 

History

History
187 lines (150 loc) · 6.99 KB

MouseManager.md

File metadata and controls

187 lines (150 loc) · 6.99 KB

Classes

MouseManagerEventEmitter

Constants

keymap : Object

Object containing "MOUSE" array of key codes.

state : Object

Object containing the state of the mouse buttons.

Interfaces

MouseEventArgs : Object

This type is used to define the parameters of the Mouse Listener event (mouseevent) data.

MouseEvent : Object

This type is used to define the parameters of the Mouse Listener event (mouseevent). available event names:

  • MOUSE_MOTION: mouse moved (no button pressed / hover)
  • MOUSE_DRAG: Valorized xFrom and yFrom. Use left or right to know which button is pressed.
  • MOUSE_LEFT_BUTTON_PRESS
  • MOUSE_LEFT_BUTTON_RELEASE
  • MOUSE_RIGHT_BUTTON_PRESS
  • MOUSE_RIGHT_BUTTON_RELEASE
  • MOUSE_MIDDLE_BUTTON_PRESS
  • MOUSE_MIDDLE_BUTTON_RELEASE
  • MOUSE_WHEEL_UP
  • MOUSE_WHEEL_DOWN
RelativeMouseEvent : Object

This type is used to define the parameters of the Mouse Listener event (mouseevent) data, relative to a widget.

MouseEventArgs : Object

This type is used to define the parameters of the Mouse Listener event (mouseevent) data.

Kind: global interface
Properties

Name Type Description
code string

The code of the pressed key.

alt boolean

If the alt key is pressed.

ctrl boolean

If the ctrl key is pressed.

shift boolean

If the shift key is pressed.

left boolean

If the left mouse key is pressed.

right boolean

If the right mouse key is pressed.

x number

The x position of the mouse (terminal column).

y number

The y position of the mouse (terminal row).

xFrom number | null

The original x position of the mouse (terminal column) when the drag started.

yFrom number | null

The original y position of the mouse (terminal row) when the drag started.

Example

const mouseEventArgs = { code: "MOUSE", alt: false, ctrl: false, shift: false, left: true, right: false, x: 10, y: 10, xFrom: null, yFrom: null }

MouseEvent : Object

This type is used to define the parameters of the Mouse Listener event (mouseevent). available event names:

  • MOUSE_MOTION: mouse moved (no button pressed / hover)
  • MOUSE_DRAG: Valorized xFrom and yFrom. Use left or right to know which button is pressed.
  • MOUSE_LEFT_BUTTON_PRESS
  • MOUSE_LEFT_BUTTON_RELEASE
  • MOUSE_RIGHT_BUTTON_PRESS
  • MOUSE_RIGHT_BUTTON_RELEASE
  • MOUSE_MIDDLE_BUTTON_PRESS
  • MOUSE_MIDDLE_BUTTON_RELEASE
  • MOUSE_WHEEL_UP
  • MOUSE_WHEEL_DOWN

Kind: global interface
Properties

Name Type Description
name string

The name of the event.

eaten number

The number of eaten events.

args MouseEventArgs

The arguments of the event.

Example

const mouseEvent = { name: "MOUSE_MOTION", eaten: 0, args: { code: "MOUSE", alt: false, ctrl: false, shift: false, left: true, right: false, x: 10, y: 10, xFrom: null, yFrom: null } }

RelativeMouseEvent : Object

This type is used to define the parameters of the Mouse Listener event (mouseevent) data, relative to a widget.

Kind: global interface
Properties

Name Type Description
name string

The name of the event.

data object

The data of the event.

data.x number

The x position of the mouse (terminal column).

data.y number

The y position of the mouse (terminal row).

MouseManager ⇐ EventEmitter

Kind: global class
Extends: EventEmitter
Emits: event:mouseevent - The mouse event.

new MouseManager(Terminal)

This class is used to manage the mouse tracking events.

MouseManager

Emits the following events:

  • "mouseevent" when the user confirm
  • "error" when an error occurs
Param Type Description
Terminal object

The terminal object (process.stdout).

Example

const mouse = new MouseManager(process.stdout)

mouseManager.enableMouse()

Enables "mouseevent" event on the input stream. Note that stream must be an output stream (i.e. a Writable Stream instance), usually process.stdout.

Kind: instance method of MouseManager
Api: public

mouseManager.disableMouse()

Disables "mouseevent" event from being sent to the input stream. Note that stream must be an output stream (i.e. a Writable Stream instance), usually process.stdout.

Kind: instance method of MouseManager
Api: public

mouseManager.isMouseFrame(key) ⇒ number

Test if the key is a part of the mouse event.

Kind: instance method of MouseManager
Returns: number -

  • 1 if the key is the header of a mouse event, -1 if is a body part, 0 otherwise.
Param Type Description
key Object

The key object to test.

keymap : Object

Object containing "MOUSE" array of key codes.

Kind: global constant

state : Object

Object containing the state of the mouse buttons.

Kind: global constant