- I
Remarks
Examples
KeyboardInputMode is installed as a child mode of a GraphEditorInputMode or GraphViewerInputMode and can be retrieved from the keyboardInputMode property.const keyboardInputMode = mode.keyboardInputMode// Execute the command if the Insert key is pressed
graphEditorInputMode.keyboardInputMode.addKeyBinding(
'Insert',
ModifierKeys.NONE,
() => {
graphEditorInputMode.createNode(
graphEditorInputMode.graphComponent!.viewport.center,
)
},
)// Fit graph into viewport if the Enter key is pressed
graphEditorInputMode.keyboardInputMode.addRecognizerBinding(
(evt) => evt instanceof KeyEventArgs && evt.key === 'Enter',
() => graphComponent.fitGraphBounds(),
)See Also
Developer's Guide
Members
Constructors
Properties
Gets the canvas instance this mode is currently installed in or null.
null.Gets the installed controller.
Examples
mode.keyboardInputMode.enabled = falseSee Also
Developer's Guide
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.
Retrieves the IInputModeContext this mode has been installed in.
null if this mode is currently not installed.Implements
IInputMode.priorityMethods
Adds a Command and associated execution handlers to this instance.
When a command is already registered (which is the case for most commands), the new binding is executed first, followed by the previously registered bindings. The built-in binding is executed last. To prevent execution of earlier registrations, let the executedHandler set handled on the ExecuteCommandArgs to true.
The command will not be allowed to execute if this mode is disabled or inactive.
Parameters
- command: Command
- The command to register handlers with.
- executedHandler: function(ExecuteCommandArgs): void
- The handler for the execution.
- canExecuteHandler?: function(CanExecuteCommandArgs): void
- The handler that determines whether the
commandcan be executed,nullif the command can always be executed.
Return Value
- KeyboardInputModeBinding
- A token for the newly created command binding that can be used to later remove this binding from this instance again.
See Also
Developer's Guide
Adds an action for a specific key down event to this mode.
Parameters
- key: string
- The key that should be recognized. The value of a key corresponds to KeyboardEvent.key. It is treated as case-insensitive and the
modifiersare handled separately. - modifiers: ModifierKeys
- The modifiers that should be recognized when the key is pressed.
- action: function
- The action that will be invoked if the given key down event is recognized.
Return Value
- KeyboardInputModeBinding
- A token for the newly created command binding that can be used to later remove this binding from this instance again.
Examples
// Execute the command if the Insert key is pressed
graphEditorInputMode.keyboardInputMode.addKeyBinding(
'Insert',
ModifierKeys.NONE,
() => {
graphEditorInputMode.createNode(
graphEditorInputMode.graphComponent!.viewport.center,
)
},
)See Also
Developer's Guide
addRecognizerBinding
(recognizer: function(EventArgs, unknown): boolean, action: function): KeyboardInputModeBindingAdds a given action to this instance that will be triggered if the given event recognizer recognizes a key event that has been triggered by the canvasComponent.
addRecognizerBinding
(recognizer: function(EventArgs, unknown): boolean, action: function): KeyboardInputModeBindingaction to this instance that will be triggered if the given event recognizer recognizes a key event that has been triggered by the canvasComponent.Parameters
- recognizer: function(EventArgs, unknown): boolean
- An event recognizer that will be fed with all key events.
- action: function
- The action to invoke if the recognizer matches an event.
Return Value
- KeyboardInputModeBinding
- A token for the newly created command binding that can be used to later remove this binding from this instance again.
See Also
Developer's Guide
This will be called prior to the uninstalling of this instance and when other input modes temporarily acquire the mutex.
In order to stop an active input mode manually, client code should use the following idiom:
if (!mode.tryStop()) {
mode.cancel()
}Implements
IInputMode.cancelInstalls this mode into the given context that is provided by the canvas.
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
- 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
API
- uninstall
Implements
IInputMode.installCalled after cancel has been called.
Can be overridden in subclasses to perform additional actions after the mode has been canceled.
This implementation does nothing.
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.
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.
Can be overridden in subclasses to perform additional actions after the mode has been stopped.
This implementation does nothing.
Triggers the text-input event.
Overridden to only return true if this instance does not currently have the input mutex.
true if this instance does not currently have the input mutex.Uninstalls this mode from the given context.
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
- context: IInputModeContext
- The context to deregister from. This is the same instance that had been passed to install during installation.
Implements
IInputMode.uninstallEvents
Occurs when text was input, but the event was not handled or did not match a command.
Properties of
TextEventArgs- context: IInputModeContext
- Gets the context for the current event.
- text: string
- Gets the text that was or will be edited.