API Docs for: 2.0.0
Show:

Input Class

Extends Component
Module: input
Parent Module: BIMSURFER

Publishes key and mouse events that occur on the parent Viewer's Canvas.

Overview

  • Each Viewer provides an Input on itself as a read-only property.

Example

In this example, we're subscribing to some mouse and key events that will occur on a Viewer's Canvas.

var viewer = new BIMSURFER.Viewer(...);

var input = viewer.input;

// We'll save a handle to this subscription
// to show how to unsubscribe, further down
var handle = input.on("mousedown", function(coords) {
      console.log("Mouse down at: x=" + coords[0] + ", y=" + coords[1]);
});

input.on("mouseup", function(coords) {
      console.log("Mouse up at: x=" + coords[0] + ", y=" + coords[1]);
});

input.on("mouseclicked", function(coords) {
     console.log("Mouse clicked at: x=" + coords[0] + ", y=" + coords[1]);
});

input.on("dblclick", function(coords) {
      console.log("Double-click at: x=" + coords[0] + ", y=" + coords[1]);
});

input.on("keydown", function(keyCode) {
       switch (keyCode) {

           case this.KEY_A:
              console.log("The 'A' key is down");
              break;

           case this.KEY_B:
              console.log("The 'B' key is down");
              break;

           case this.KEY_C:
              console.log("The 'C' key is down");
              break;

           default:
              console.log("Some other key is down");
      }
    });

input.on("keyup", function(keyCode) {
       switch (keyCode) {

           case this.KEY_A:
              console.log("The 'A' key is up");
              break;

           case this.KEY_B:
              console.log("The 'B' key is up");
              break;

           case this.KEY_C:
              console.log("The 'C' key is up");
              break;

           default:
              console.log("Some other key is up");
       }
    });

// TODO: ALT and CTRL keys etc

Unsubscribing from Events

In the snippet above, we saved a handle to one of our event subscriptions.

We can then use that handle to unsubscribe again, like this:

input.off(handle);

Methods

destroy

()

Destroys this component.

Removes this Component from its Viewer.

Fires a destroyed event on this Component.

error

(
  • message
)

Logs an error for this component to the JavaScript console.

The console message will have this format: [ERROR] <component id>: <message>

Parameters:

  • message String

    The message to log

fire

(
  • event
  • value
  • [forget=false]
)

Fires an event on this component.

Notifies existing subscribers to the event, retains the event to give to any subsequent notifications on that location as they are made.

Parameters:

  • event String

    The event type name

  • value Object

    The event

  • [forget=false] Boolean optional

    When true, does not retain for subsequent subscribers

log

(
  • message
)

Logs a console debugging message for this component.

The console message will have this format: [LOG] <component id>: <message>

Parameters:

  • message String

    The message to log

off

(
  • handle
)

Cancels an event subscription that was previously made with on or once.

Parameters:

  • handle String

    Subscription handle

on

(
  • event
  • callback
  • [scope=this]
)
String

Subscribes to an event on this component.

The callback is be called with this component as scope.

Parameters:

  • event String

    Publication event

  • callback Function

    Called when fresh data is available at the event

  • [scope=this] Object optional

    Scope for the callback

Returns:

String:

Handle to the subscription, which may be used to unsubscribe with {@link #off}.

once

(
  • event
  • callback
  • [scope=this]
)

Subscribes to the next occurrence of the given event, then un-subscribes as soon as the event is handled.

Parameters:

  • event String

    Data event to listen to

  • callback Function(data)

    Called when fresh data is available at the event

  • [scope=this] Object optional

    Scope for the callback

warn

(
  • message
)

Logs a warning for this component to the JavaScript console.

The console message will have this format: [WARN] <component id>: <message>

Parameters:

  • message String

    The message to log

Properties

className

String final

JavaScript class name for this Component.

destroyed

Boolean

True as soon as this Component has been destroyed

id

String final

Unique ID for this Component within its parent Viewer.

Items in this map

Unknown

KEY_A

Number final

Code for the A key.

KEY_ADD

Number final

Code for the ADD key.

KEY_ALT

Number final

Code for the ALT key.

KEY_B

Number final

Code for the B key.

KEY_BACK_SLASH

Number final

Code for the BACK_SLASH key.

KEY_BACKSPACE

Number final

Code for the BACKSPACE key.

KEY_C

Number final

Code for the C key.

KEY_CAPS_LOCK

Number final

Code for the CAPS_LOCK key.

KEY_CLOSE_BRACKET

Number final

Code for the CLOSE_BRACKET key.

KEY_COMMA

Number final

Code for the COMMA key.

KEY_CTRL

Number final

Code for the CTRL key.

KEY_D

Number final

Code for the D key.

KEY_DASH

Number final

Code for the DASH key.

KEY_DECIMAL_POINT

Number final

Code for the DECIMAL POINT key.

KEY_DELETE

Number final

Code for the DELETE key.

KEY_DIVIDE

Number final

Code for the DIVIDE key.

KEY_DOWN_ARROW

Number final

Code for the DOWN_ARROW key.

KEY_E

Number final

Code for the E key.

KEY_END

Number final

Code for the END key.

KEY_ENTER

Number final

Code for the ENTER key.

KEY_EQUAL_SIGN

Number final

Code for the EQUAL_SIGN key.

KEY_ESCAPE

Number final

Code for the ESCAPE key.

KEY_F

Number final

Code for the F key.

KEY_F1

Number final

Code for the F1 key.

KEY_F10

Number final

Code for the F10 key.

KEY_F11

Number final

Code for the F11 key.

KEY_F12

Number final

Code for the F12 key.

KEY_F2

Number final

Code for the F2 key.

KEY_F3

Number final

Code for the F3 key.

KEY_F4

Number final

Code for the F4 key.

KEY_F5

Number final

Code for the F5 key.

KEY_F6

Number final

Code for the F6 key.

KEY_F7

Number final

Code for the F7 key.

KEY_F8

Number final

Code for the F8 key.

KEY_F9

Number final

Code for the F9 key.

KEY_FORWARD_SLASH

Number final

Code for the FORWARD_SLASH key.

KEY_G

Number final

Code for the G key.

KEY_GRAVE_ACCENT

Number final

Code for the GRAVE_ACCENT key.

KEY_H

Number final

Code for the H key.

KEY_HOME

Number final

Code for the HOME key.

KEY_I

Number final

Code for the I key.

KEY_INSERT

Number final

Code for the INSERT key.

KEY_J

Number final

Code for the J key.

KEY_K

Number final

Code for the K key.

KEY_L

Number final

Code for the L key.

KEY_LEFT_ARROW

Number final

Code for the LEFT_ARROW key.

KEY_LEFT_WINDOW

Number final

Code for the LEFT_WINDOW key.

KEY_M

Number final

Code for the M key.

KEY_MULTIPLY

Number final

Code for the MULTIPLY key.

KEY_N

Number final

Code for the N key.

KEY_NUM_0

Number final

Code for the 0 key.

KEY_NUM_1

Number final

Code for the 1 key.

KEY_NUM_2

Number final

Code for the 2 key.

KEY_NUM_3

Number final

Code for the 3 key.

KEY_NUM_4

Number final

Code for the 4 key.

KEY_NUM_5

Number final

Code for the 5 key.

KEY_NUM_6

Number final

Code for the 6 key.

KEY_NUM_7

Number final

Code for the 7 key.

KEY_NUM_8

Number final

Code for the 8 key.

KEY_NUM_9

Number final

Code for the 9 key.

KEY_NUM_LOCK

Number final

Code for the NUM_LOCK key.

KEY_NUMPAD 2

Number final

Code for the number pad 2 key.

KEY_NUMPAD_0

Number final

Code for the number pad 0 key.

KEY_NUMPAD_1

Number final

Code for the number pad 1 key.

KEY_NUMPAD_3

Number final

Code for the number pad 3 key.

KEY_NUMPAD_4

Number final

Code for the number pad 4 key.

KEY_NUMPAD_5

Number final

Code for the number pad 5 key.

KEY_NUMPAD_6

Number final

Code for the number pad 6 key.

KEY_NUMPAD_7

Number final

Code for the number pad 7 key.

KEY_NUMPAD_8

Number final

Code for the number pad 8 key.

KEY_NUMPAD_9

Number final

Code for the number pad 9 key.

KEY_O

Number final

Code for the O key.

KEY_OPEN_BRACKET

Number final

Code for the OPEN_BRACKET key.

KEY_P

Number final

Code for the P key.

KEY_PAGE_DOWN

Number final

Code for the PAGE_DOWN key.

KEY_PAGE_UP

Number final

Code for the PAGE_UP key.

KEY_PAUSE_BREAK

Number final

Code for the PAUSE_BREAK key.

KEY_PERIOD

Number final

Code for the PERIOD key.

KEY_Q

Number final

Code for the Q key.

KEY_R

Number final

Code for the R key.

KEY_RIGHT_ARROW

Number final

Code for the RIGHT_ARROW key.

KEY_RIGHT_WINDOW

Number final

Code for the RIGHT_WINDOW key.

KEY_S

Number final

Code for the S key.

KEY_SCROLL_LOCK

Number final

Code for the SCROLL_LOCK key.

KEY_SELECT

Number final

Code for the SELECT key.

KEY_SEMI_COLON

Number final

Code for the SEMI_COLON key.

KEY_SHIFT

Number final

Code for the SHIFT key.

KEY_SINGLE_QUOTE

Number final

Code for the SINGLE_QUOTE key.

KEY_SPACE

Number final

Code for the SPACE key.

KEY_SUBTRACT

Number final

Code for the SUBTRACT key.

KEY_T

Number final

Code for the T key.

KEY_TAB

Number final

Code for the TAB key.

KEY_U

Number final

Code for the U key.

KEY_UP_ARROW

Number final

Code for the UP_ARROW key.

KEY_V

Number final

Code for the V key.

KEY_W

Number final

Code for the W key.

KEY_X

Number final

Code for the X key.

KEY_Y

Number final

Code for the Y key.

KEY_Z

Number final

Code for the Z key.

metadata

Object

Metadata on this component.

viewer

Viewer final

The Viewer that contains this Component.

Events

dblclick

Fired whenever the mouse is double-clicked over the parent Viewer's Canvas.

Event Payload:

  • value Number, Number

    The mouse coordinates within the Canvas,

destroyed

Fired when this Component is destroyed.

keydown

Fired whenever a key is pressed while the parent Viewer's Canvas has input focus.

Event Payload:

keyup

Fired whenever a key is released while the parent Viewer's Canvas has input focus.

Event Payload:

mouseclicked

Fired whenever the mouse is clicked over the parent Viewer's Canvas.

Event Payload:

  • value Number, Number

    The mouse coordinates within the Canvas,

mousedown

Fired whenever the mouse is pressed over the parent Viewer's Canvas.

Event Payload:

  • value Number, Number

    The mouse coordinates within the Canvas,

mousedown

Fired whenever the mouse is moved over the parent Viewer's Canvas.

Event Payload:

  • value Number, Number

    The mouse coordinates within the Canvas,

mouseup

Fired whenever the mouse is released over the parent Viewer's Canvas.

Event Payload:

  • value Number, Number

    The mouse coordinates within the Canvas,

mousewheel

Fired whenever the mouse wheel is moved over the parent Viewer's Canvas.

Event Payload:

  • delta Number

    The mouse wheel delta,