- I
Remarks
This mode will render a visual representation of IHandles in the CanvasComponent and deal with mouse gestures that drag the visual representations accordingly.
This mode is exclusive by default.
Examples
Typically, the HandleInputMode is installed as child mode of a GraphEditorInputMode and can be retrieved from the handleInputMode property.
const handleInputMode = mode.handleInputModeIf one needs to execute some code after some items have been moved by the HandleInputMode, he can register a handler to its drag-finished event. The moved items can be retrieved from the affectedItems property:
mode.handleInputMode.addEventListener('drag-finished', () => {
for (const item of mode.handleInputMode.affectedItems) {
// these items have been moved
}
})mode.moveViewportInputMode.allowSinglePointerMovement = true
mode.createBendInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.createEdgeInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.handleInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.lassoSelectionInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.marqueeSelectionInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWN
mode.moveSelectedItemsInputMode.beginRecognizerTouch =
EventRecognizers.TOUCH_PRIMARY_DOWNSee Also
Developer's Guide
API
- IHandle
Members
Constructors
Properties
Gets an immutable snapshot of the IModelItems affected by the currently modified handle gesture.
When the gesture is starting and the currentHandle is initialized, the implementation can register the affected item(s) through the IModelItemCollector instance that is bound to the context available via its lookup.
Client code can register with the drag-started event, as well as the drag-finished event to get notified of the elements that may be or have been affected respectively by this input mode.
Property Value
Examples
mode.handleInputMode.addEventListener('drag-finished', () => {
for (const item of mode.handleInputMode.affectedItems) {
// these items have been moved
}
})See Also
Developer's Guide
Gets or sets the event recognizer that determines whether to start moving the handle.
Gets or sets the event recognizer that determines whether to cancel moving the handle.
Gets or sets the event recognizer that determines whether a handle was clicked.
Gets the installed controller.
Gets the handle that is currently being moved or null otherwise.
null otherwise.Property Value
null.Gets or sets the event recognizer that can be used by handle implementations to constrain the handle movement.
Gets or sets the event recognizer that determines whether to temporarily disable snapping.
Clients can use this property to disable or reenable this instance. This will set the enabled property of the installed controller so a disabled instance should never try to acquire the input mutex.
Disabling this mode will hide the handles and prevent the user from interacting with them.
Examples
mode.handleInputMode.enabled = falseGets or sets the event recognizer that determines whether to re-enable temporarily disabled snapping.
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 or sets the event recognizer that determines whether to finish moving the handle.
Gets or sets the event recognizer that determines whether to finish moving the handle via touch.
Gets or sets the collection of IHandles this mode manages.
Gets or sets the IObjectRenderer<HandlesRenderTag> that visualizes this input mode's handles.
When queried for an IVisualCreator to obtain the visualizations for the handles, this renderer is passed instances of HandlesRenderTag as render tag.
The default handlesRenderer is HandlesRenderer which automatically uses WebGL when WebGLGraphModelManager is set as graphModelManager, otherwise the SVG is used.
Custom renderers must not use the handle's location directly when positioning handles, since handles may have an offset. To apply this offset, the handle location must first be transformed into intermediate coordinates before applying the handle offset.
Property Value
Gets or sets the event recognizer that determines whether to move the handle.
Retrieves the IInputModeContext this mode has been installed in.
null if this mode is currently not installed. Use createInputModeContext to obtain a context that has this IInputMode as the inputMode.Implements
IInputMode.priorityGets or sets whether to request the mutex when beginRecognizer or beginRecognizerTouch was triggered.
true this will discard other concurrent input modes when a handle was pressed. Otherwise, the mutex is only requested as soon as the drag gesture starts. The default is true.See Also
Gets or sets the GraphSnapContext which manages snapping model items to certain coordinates (for instance, other items).
If set to null (the default) this input mode tries to obtain the GraphSnapContext from the IInputModeContext. To explicitly disable snapping, a GraphSnapContext implementation that is disabled needs to be set.
Default is null.
This only makes a difference if the projection is different from the IDENTITY transform.
The default value is to draw handles in the intermediate coordinate system.
See Also
Developer's Guide
Methods
Adds a handle to the collection of handles managed by this instance.
Factory method that creates and adds a handle to this mode by wrapping a given IMutablePoint instance.
Parameters
- location: IMutablePoint
- The point to use as a handle.
- cursor?: Cursor
- The cursor to use.
- type?: HandleType
- The type of the handle to create.
Return Value
- IHandle
- The handle created.
Invoked when this mode gets "armed".
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.cancelCreates an IInputModeContext for use with the IHandle interface for the upcoming drag operation.
Helper method that yields a suitably configured InputModeEventArgs for this input mode.
Parameters
- location: Point
- The coordinates in the world coordinate system.
Return Value
- IHandle
- The closest handle that has been hit or
null
See Also
Finds the closest hit handle for the given world coordinate pair.
Parameters
- location: Point
- The coordinates in the world coordinate system.
- pointerType: PointerType
- The pointer-type of the last input event.
Return Value
- IHandle
- The closest handle that has been hit or
null
Parameters
- context: IInputModeContext
- The current input mode context.
- evt: ClickEventArgs
- Arguments describing the click.
- handle: IHandle
- The handle that was clicked.
Parameters
- handle: IHandle
- The handle to check
- location: Point
- The view coordinates to check.
- distance: Point
- The distance of the handle to the location. In the default implementation, this is a tuple representing the x- and y-distance of the handle to the location.
- pointerType: PointerType
- The last event's pointer type to consider.
Return Value
- boolean
- Whether the handle has been hit.
Installs the visual representation of the handles into the canvas into the inputModeGroup.
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.
Implements
IInputMode.installInvalidates the canvas this mode is currently installed in.
Returns whether this input mode has the mutex and the directionalConstraintRecognizer recognized a directional constrained move for the lastInputEvent.
Return Value
- boolean
true, if this input mode has the mutex and the last input event was recognized by the directionalConstraintRecognizer,falseotherwise.
Returns whether this input mode has the mutex and the disableSnappingRecognizer recognized that snapping shall be temporarily disabled.
Return Value
- boolean
true, if this input mode has the mutex and snapping is temporarily disabled,falseotherwise.
Called after cancel has been called.
Can be overridden in subclasses to perform additional actions after the mode has been canceled.
This implementation does nothing.
Triggers the clicked event.
Parameters
- evt: ClickEventArgs
- The event argument that contains context information.
Can be overridden in subclasses to perform additional actions after the mode has been activated.
Overriding implementations should call the base implementation.
Can be overridden in subclasses to perform additional actions after the mode has been deactivated.
Overriding implementations should call the base implementation.
Triggers the drag-canceled event.
Triggers the drag-canceling event.
Triggered once the drag has been finalized.
Parameters
- evt: InputModeEventArgs
- The event argument that contains context information.
Triggered before the drag will be finalized.
Parameters
- evt: InputModeEventArgs
- The event argument that contains context information.
Triggered at the end of each drag.
Parameters
- evt: InputModeEventArgs
- The event argument that contains context information.
Triggered at the start of each drag.
Parameters
- evt: InputModeEventArgs
- The event argument that contains context information.
Triggers the drag-started event.
Triggers the drag-starting event.
Raises the query-closest-handle event.
Parameters
- evt: QueryClosestHandleEventArgs
- The query-closest-handle instance containing the event data.
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.
Removes a handle from the collection of handles managed by this instance.
Parameters
- handle: IHandle
- The handle to be dragged.
Return Value
falseReturn Value
- boolean
trueif and only if the editing has been stopped or there was no edit in progress
Implements
IInputMode.tryStopRemoves the IRenderTreeElement that displays the handles from the canvas.
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 a handle has been clicked or tapped.
Properties of
ClickEventArgs- altKey: boolean
- Gets a value indicating whether the alt modifier was pressed at the time of the click.
- clickCount: number
- Gets the number of clicks associated with this event.
- context: IInputModeContext
- Gets the context for the current event.
- ctrlKey: boolean
- Gets a value indicating whether the control modifier was pressed at the time of the click.
- handled: booleanwritable
- Gets or sets a value indicating whether this instance has been handled.
- location: Point
- Gets the location of the click.
- metaKey: boolean
- Gets a value indicating whether the meta modifier was pressed at the time of the click.
- modifiers: ModifierKeys
- Gets the state of the modifiers at the time of the click.
- originalEventArgs: PointerEventArgs
- Gets the pointer event args that caused this event.
- pointerButtons: PointerButtons
- Gets the PointerButtons that have changed for this event.
- pointerType: PointerType
- Gets the type of the pointer that was the source of this event.
- shiftKey: boolean
- Gets a value indicating whether the shift modifier was pressed at the time of the click.
Occurs when the drag has been canceled.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs before the drag will be canceled.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs once the drag has been finished.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
Examples
mode.handleInputMode.addEventListener('drag-finished', () => {
for (const item of mode.handleInputMode.affectedItems) {
// these items have been moved
}
})See Also
Developer's Guide
Occurs before the drag will be finished.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs once the drag is initialized and has started.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs once the drag is starting.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs at the end of every drag.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs at the start of every drag.
Properties of
InputModeEventArgs- context: IInputModeContext
- Gets the context for the current event.
See Also
Developer's Guide
Occurs when this mode queries the closest handle for a certain query location.
Properties of
QueryClosestHandleEventArgs- context: IInputModeContext
- Gets the context for the current event.
- handle: IHandlewritable
- Gets or sets the handle to use.
- handled: booleanwritable
- Gets or sets a value indicating whether this QueryClosestHandleEventArgs instance has been handled.
- queryLocation: Point
- Gets the query location in world coordinates.