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.
Bind the delete key to the delete action in an existing editor.
var keyHandler = new mxDefaultKeyHandler(editor); keyHandler.bindAction(46, 'delete');
This class uses the mxDefaultKeyHandlerCodec to read configuration data into an existing instance. See mxDefaultKeyHandlerCodec for a description of the configuration format.
See mxKeyHandler.
An mxEvent.ESCAPE event is fired via the editor if the escape key is pressed.
mxDefaultKeyHandler | Binds keycodes to actionnames in an editor. |
Functions | |
mxDefaultKeyHandler | Constructs a new default key handler for the mxEditor.graph in the given mxEditor. |
Variables | |
editor | Reference to the enclosing mxEditor. |
handler | Holds the mxKeyHandler for key event handling. |
Functions | |
bindAction | Binds the specified keycode to the given action in editor. |
destroy | Destroys the handler associated with this object. |
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.)
editor | Reference to the enclosing mxEditor. |
mxDefaultKeyHandler.prototype.editor
Reference to the enclosing mxEditor.
mxDefaultKeyHandler.prototype.handler
Holds the mxKeyHandler for key event handling.
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.
code | Integer that specifies the keycode. |
action | Name of the action to execute in editor. |
control | Optional boolean that specifies if control must be pressed. Default is false. |
Constructs a new default key handler for the mxEditor.graph in the given mxEditor.
function mxDefaultKeyHandler( editor )
Holds a mxGraph for displaying the diagram.
mxEditor.prototype.graph
Reference to the enclosing mxEditor.
mxDefaultKeyHandler.prototype.editor
Holds the mxKeyHandler for key event handling.
mxDefaultKeyHandler.prototype.handler
Binds the specified keycode to the given action in editor.
mxDefaultKeyHandler.prototype.bindAction = function ( code, action, control )
Destroys the handler associated with this object.
mxDefaultKeyHandler.prototype.destroy = function ()
Hook to process ESCAPE keystrokes.
mxKeyHandler.prototype.escape = function( evt )
Holds a mxDefaultKeyHandler for handling keyboard events.
mxEditor.prototype.keyHandler
Specifies the event name for escape.
ESCAPE: 'escape'