mxDefaultKeyHandler

Binds keycodes to actionnames in an editor.  This aggregates an internal handler and extends the implementation of mxKeyHandler.escape to not only cancel the editing, but also hide the properties dialog and fire an <mxEditor.escape> event via editor.  An instance of this class is created by mxEditor and stored in mxEditor.keyHandler.

Example

Bind the delete key to the delete action in an existing editor.

var keyHandler = new mxDefaultKeyHandler(editor);
keyHandler.bindAction(46, 'delete');

Codec

This class uses the mxDefaultKeyHandlerCodec to read configuration data into an existing instance.  See mxDefaultKeyHandlerCodec for a description of the configuration format.

Keycodes

See mxKeyHandler.

An mxEvent.ESCAPE event is fired via the editor if the escape key is pressed.

Summary
mxDefaultKeyHandlerBinds keycodes to actionnames in an editor.
Functions
mxDefaultKeyHandlerConstructs a new default key handler for the mxEditor.graph in the given mxEditor.
Variables
editorReference to the enclosing mxEditor.
handlerHolds the mxKeyHandler for key event handling.
Functions
bindActionBinds the specified keycode to the given action in editor.
destroyDestroys the handler associated with this object.

Functions

mxDefaultKeyHandler

function mxDefaultKeyHandler(editor)

Constructs a new default key handler for the mxEditor.graph in the given mxEditor.  (The editor may be null if a prototypical instance for a mxDefaultKeyHandlerCodec is created.)

Parameters

editorReference to the enclosing mxEditor.

Variables

editor

mxDefaultKeyHandler.prototype.editor

Reference to the enclosing mxEditor.

handler

mxDefaultKeyHandler.prototype.handler

Holds the mxKeyHandler for key event handling.

Functions

bindAction

mxDefaultKeyHandler.prototype.bindAction = function (code,
action,
control)

Binds the specified keycode to the given action in editor.  The optional control flag specifies if the control key must be pressed to trigger the action.

Parameters

codeInteger that specifies the keycode.
actionName of the action to execute in editor.
controlOptional boolean that specifies if control must be pressed.  Default is false.

destroy

mxDefaultKeyHandler.prototype.destroy = function ()

Destroys the handler associated with this object.  This does normally not need to be called, the handler is destroyed automatically when the window unloads (in IE) by mxEditor.

function mxDefaultKeyHandler(editor)
Constructs a new default key handler for the mxEditor.graph in the given mxEditor.
mxEditor.prototype.graph
Holds a mxGraph for displaying the diagram.
Extends mxEventSource to implement an application wrapper for a graph that adds actions, I/O using mxCodec, auto-layout using mxLayoutManager, command history using undoManager, and standard dialogs and widgets, eg.
mxDefaultKeyHandler.prototype.editor
Reference to the enclosing mxEditor.
mxDefaultKeyHandler.prototype.handler
Holds the mxKeyHandler for key event handling.
Event handler that listens to keystroke events.
mxDefaultKeyHandler.prototype.bindAction = function (code,
action,
control)
Binds the specified keycode to the given action in editor.
mxDefaultKeyHandler.prototype.destroy = function ()
Destroys the handler associated with this object.
mxKeyHandler.prototype.escape = function(evt)
Hook to process ESCAPE keystrokes.
mxEditor.prototype.keyHandler
Holds a mxDefaultKeyHandler for handling keyboard events.
Custom codec for configuring mxDefaultKeyHandlers.
ESCAPE: 'escape'
Specifies the event name for escape.
Close