An IInputMode that recognizes simple key events and invokes a registered handler.
Remarks
Examples
KeyboardInputMode
is installed as child mode of a GraphEditorInputMode or GraphViewerInputMode and can be retrieved from the keyboardInputMode property.Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.input.KeyboardInputMode
See Also
Constructors
Initializes a new instance of the KeyboardInputMode class.
Parameters
A map of options to pass to the method.
- priority - number
- exclusive - boolean
A value indicating whether this mode will be the only one running when it has the mutex. This option sets the exclusive property on the created object.
- enabled - boolean
The enabled state of this input mode. This option sets the enabled property on the created object.
Properties
Gets the installed controller.
Gets or sets the enabled state of this input mode.
Remarks
Examples
Gets or sets a value indicating whether this mode will be the only one running when it has the mutex.
Remarks
The value of this property will be delegated to the exclusive property of the controller.
If this mode is marked as exclusive and has the mutex, all other modes added to the same MultiplexingInputMode will be deactivated. Otherwise it will always run concurrently with all other modes.
Gets the context instance this mode is currently installed in or null
if this instance is not installed.
Remarks
Implements
Gets the priority of this input mode.
Remarks
See Also
Implements
Methods
addCommandBinding
(command: ICommand, execute?: function(ICommand, Object, Object):boolean, canExecute?: function(ICommand, Object, Object):boolean) : KeyboardInputModeBindingAdds a command and associated execution handlers to this instance.
Remarks
Parameters
A map of options to pass to the method.
- command - ICommand
- The command to register handlers with.
- execute - function(ICommand, Object, Object):boolean
- The handler for the execution.
Signature Details
function(command: ICommand, parameter: any, source: any) : boolean
Function signature for a callback that executes a given ICommand for the given parameter setParameters
- command - ICommand
- The command to execute.
- parameter - any
- The optional parameter for the command execution.
- source - any
- The source for which the command shall be executed.
Returns
- boolean
- Return
true
to indicate that the action was handled and executed successfully by this handler. Note that currently this return value is ignored. In a future version, it can be used to support multiple execution handlers. The list of execution handlers would then be traversed until the first handler yieldstrue
. Returningfalse
would then mean to run the default or fallback action, instead, if any. So although currently it doesn't matter what gets returned, returningtrue
will probably be the correct value in future versions of yFiles.
- canExecute - function(ICommand, Object, Object):boolean
- The handler that determines executability or always enabled if omitted.
Signature Details
function(command: ICommand, parameter: any, source: any) : boolean
Function signature for a callback that determines whether a given ICommand can be executed for the given parameter set.Parameters
- command - ICommand
- The command to test executability.
- parameter - any
- The optional parameter for the command execution.
- source - any
- The source for which the command shall be executed.
Returns
- boolean
true
, iff the command can been executed for the given parameter set.
Returns
- ↪KeyboardInputModeBinding
- A token for the newly created command binding that can used to later remove this binding from this instance again.
See Also
addKeyBinding
(key: Key, modifiers: ModifierKeys, command: ICommand, commandParameter?: Object) : KeyboardInputModeBindingAdds an event handler for a specific key press gesture to this mode.
Remarks
Parameters
A map of options to pass to the method.
- key - Key
- The key constant that should be recognized.
- modifiers - ModifierKeys
- The modifiers that should be recognized when the key is pressed.
- command - ICommand
- The command to execute.
- commandParameter - Object
- The command parameter to use for the execution;
null
if omitted.
Returns
- ↪KeyboardInputModeBinding
- A token for the newly created command binding that can used to later remove this binding from this instance again.
See Also
addKeyBinding
(key: Key, modifiers?: ModifierKeys, execute?: function(ICommand, Object, Object):boolean, canExecute?: function(ICommand, Object, Object):boolean) : KeyboardInputModeBindingAdds an event handler for a specific key press gesture to this mode.
Parameters
A map of options to pass to the method.
- key - Key
- The key constant that should be recognized.
- modifiers - ModifierKeys
- The modifiers that should be recognized when the key is pressed. Defaults to NONE if omitted.
- execute - function(ICommand, Object, Object):boolean
- The handler for the execution.
Signature Details
function(command: ICommand, parameter: any, source: any) : boolean
Function signature for a callback that executes a given ICommand for the given parameter setParameters
- command - ICommand
- The command to execute.
- parameter - any
- The optional parameter for the command execution.
- source - any
- The source for which the command shall be executed.
Returns
- boolean
- Return
true
to indicate that the action was handled and executed successfully by this handler. Note that currently this return value is ignored. In a future version, it can be used to support multiple execution handlers. The list of execution handlers would then be traversed until the first handler yieldstrue
. Returningfalse
would then mean to run the default or fallback action, instead, if any. So although currently it doesn't matter what gets returned, returningtrue
will probably be the correct value in future versions of yFiles.
- canExecute - function(ICommand, Object, Object):boolean
- The handler that determines executability or always enabled if omitted.
Signature Details
function(command: ICommand, parameter: any, source: any) : boolean
Function signature for a callback that determines whether a given ICommand can be executed for the given parameter set.Parameters
- command - ICommand
- The command to test executability.
- parameter - any
- The optional parameter for the command execution.
- source - any
- The source for which the command shall be executed.
Returns
- boolean
true
, iff the command can been executed for the given parameter set.
Returns
- ↪KeyboardInputModeBinding
- A token for the newly created command binding that can used to later remove this binding from this instance again.
See Also
addRecognizerBinding
(recognizer: function(Object, EventArgs):boolean, command: ICommand, commandParameter?: Object) : KeyboardInputModeBindingAdds a given handler to this instance that will be triggered if the event recognizer recognizes a key event that has been triggered by the CanvasComponent.
Parameters
A map of options to pass to the method.
- recognizer - function(Object, EventArgs):boolean
- An event recognizer that will be fed with all key events.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
- command - ICommand
- The command to invoke if the recognizer matches a key event.
- commandParameter - Object
- The optional parameter to provide to the command.
Returns
- ↪KeyboardInputModeBinding
- The newly constructed binding on which remove can be called to remove the resulting binding from this instance.
addRecognizerBinding
(recognizer: function(Object, EventArgs):boolean, execute?: function(ICommand, Object, Object):boolean, canExecute?: function(ICommand, Object, Object):boolean) : KeyboardInputModeBindingAdds a given handler to this instance that will be triggered if the event recognizer recognizes a key event that has been triggered by the CanvasComponent.
Parameters
A map of options to pass to the method.
- recognizer - function(Object, EventArgs):boolean
- An event recognizer that will be fed with all key events.
Signature Details
function(eventSource: any, evt: EventArgs) : boolean
A callback that recognizes events.Given a sender and an event argument, delegates decide whether the event is treated as a match depending on the context.Parameters
- eventSource - any
- The source of the event.
- evt - EventArgs
- The arguments of the event to be decided to handle.
Returns
- boolean
true
if theevt
is considered to be handled.
- execute - function(ICommand, Object, Object):boolean
- The handler for the execution.
Signature Details
function(command: ICommand, parameter: any, source: any) : boolean
Function signature for a callback that executes a given ICommand for the given parameter setParameters
- command - ICommand
- The command to execute.
- parameter - any
- The optional parameter for the command execution.
- source - any
- The source for which the command shall be executed.
Returns
- boolean
- Return
true
to indicate that the action was handled and executed successfully by this handler. Note that currently this return value is ignored. In a future version, it can be used to support multiple execution handlers. The list of execution handlers would then be traversed until the first handler yieldstrue
. Returningfalse
would then mean to run the default or fallback action, instead, if any. So although currently it doesn't matter what gets returned, returningtrue
will probably be the correct value in future versions of yFiles.
- canExecute - function(ICommand, Object, Object):boolean
- The handler that determines executability or always enabled if omitted.
Signature Details
function(command: ICommand, parameter: any, source: any) : boolean
Function signature for a callback that determines whether a given ICommand can be executed for the given parameter set.Parameters
- command - ICommand
- The command to test executability.
- parameter - any
- The optional parameter for the command execution.
- source - any
- The source for which the command shall be executed.
Returns
- boolean
true
, iff the command can been executed for the given parameter set.
Returns
- ↪KeyboardInputModeBinding
- The newly constructed binding on which remove can be called to remove the resulting binding from this instance.
See Also
Called by the client to unconditionally cancel all editing.
Remarks
This will be called prior to the uninstalling of this instance.
In order to stop an active input mode manually, client code should use the following idiom:
if (!mode.tryStop()) {
mode.cancel()
}
Implements
Installs this mode into the given context that is provided by the canvas.
Remarks
In general a mode can only be installed into a single canvas at all times.
This method is called to initialize this instance. Subclasses should override this method to register the corresponding event handler delegates for the various input events they need to register with.
Overriding implementations should call the base implementation, first.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context that this instance shall be installed into. The same instance will be passed to this instance during uninstall. A reference to the context may be kept and queried during the time the mode is installed.
- controller - ConcurrencyController
- The controller for this mode.
See Also
Implements
Called after cancel has been called.
Remarks
Can be overridden in subclasses to perform additional actions after the mode has been canceled.
This implementation does nothing.
Called after the active property of the installed ConcurrencyController has been set to true
.
Remarks
Enables the registered commands and can be overridden in subclasses to perform additional actions after the mode has been activated.
Overriding implementations should call the base implementation.
Called after the active property of the installed ConcurrencyController has been set to false
.
Remarks
Disables the registered commands and can be overridden in subclasses to perform additional actions after the mode has been deactivated.
Overriding implementations should call the base implementation.
Called after tryStop has been called.
Remarks
Can be overridden in subclasses to perform additional actions after the mode has been stopped.
This implementation does nothing.
Removes all previously registered commands from this instance.
Remarks
Parameters
A map of options to pass to the method.
- command - ICommand
- The command to remove from all registered bindings.
See Also
Overridden to only return true
if this instance does not currently have the input mutex.
Uninstalls this mode from the given context.
Remarks
This code should clean up all changes made to the canvas in the install method. After a mode has been uninstalled it can be installed again into the same or another canvas.
Overriding implementations should call the base implementation after their own code.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The context to deregister from. This is the same instance that had been passed to install during installation.