- I
Remarks
This mode can be used to determine when the pointer is being moved from one item to the next.
This mode is exclusive by default.
Examples
Typically, the ItemHoverInputMode is installed as child mode of a GraphEditorInputMode or GraphViewerInputMode and can be retrieved from the itemHoverInputMode property.
const itemHoverInputMode = mode.itemHoverInputModeThe ItemHoverInputMode raises the hovered-item-changed event each time the cursor hovers over a different item or the canvas, in which case the hovered item is null. One can also configure the item types which are reported:
// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
// enable the ItemHoverInputMode and let it handle edges and nodes
mode.itemHoverInputMode.enabled = true
mode.itemHoverInputMode.hoverItems =
GraphItemTypes.EDGE | GraphItemTypes.NODE
// handle changes on the hovered items
mode.itemHoverInputMode.addEventListener(
'hovered-item-changed',
(evt) => {
const oldItem = evt.oldItem
// e.g. remove the highlight from oldItem here
const newItem = evt.item
// e.g. add a highlight to newItem here
},
)See Also
Demos
- Displays sample graphs from various application domains.
Members
Constructors
Initializes a new instance of the ItemHoverInputMode class.
Parameters
Properties
Gets the installed controller.
Gets the current item the pointer is hovering over.
Property Value
null if the pointer is not hovering over a valid item.Examples
mode.itemHoverInputMode.enabled = falseThe 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 cursor to use when the pointer is hovering over a isValidHoverItem valid hover item.
Property Value
null (the default).Gets or sets which graph items are considered by this input mode.
The default is ALL.
Note that the default is set to a different value if this mode is a child mode of the GraphEditorInputMode or GraphViewerInputMode. and documented there.
Examples
// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
// enable the ItemHoverInputMode and let it handle edges and nodes
mode.itemHoverInputMode.enabled = true
mode.itemHoverInputMode.hoverItems =
GraphItemTypes.EDGE | GraphItemTypes.NODE
// handle changes on the hovered items
mode.itemHoverInputMode.addEventListener(
'hovered-item-changed',
(evt) => {
const oldItem = evt.oldItem
// e.g. remove the highlight from oldItem here
const newItem = evt.item
// e.g. add a highlight to newItem here
},
)Gets or sets a value indicating whether items that have been hit at the current location that are not valid items should be ignored (and an underlying valid item be considered instead) or reported as null.
null.This setting also has an influence, if the items you want to hover over are covered by "invalid" items in front of them. By default, these "invalid" items will stop the hover picking process and null will be reported, even if there is a valid item underneath the hovered item.
Set this to true to let hit test enumeration continue to find the next valid item. Set this to false if invalid items should be reported as null.
The default is true.
See Also
Retrieves the IInputModeContext this mode has been installed in.
null if this mode is currently not installed. Use createInputModeContext to get a context that has this IInputMode as the inputMode.Implements
IInputMode.priorityMethods
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 implementation of IInputModeContext that is specific to this mode.
This is needed for events that are triggered by this InputMode to signal where the event is coming from. A common usage for this is, for example, in isHit calls.
The result can be given to isHit or enumerateHits to let implementations of IHitTestable get access to the current IInputModeContext. This can be done by looking up IInputModeContext from the ICanvasContext's lookup method or simply down-casting.
Return Value
- IInputModeContext
- A readily configured IInputModeContext.
See Also
Gets the items that have been hit at the given location.
Parameters
- location: Point
- The location in world coordinates to query.
Return Value
- IEnumerable<IModelItem>
- An enumerable over the items that have been hit at the given location.
Installs 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.installDetermines whether the given item is a valid item to be considered for hovering.
Parameters
- item: IModelItem
- The item to check.
Return Value
- boolean
trueif it is valid to report a hover over the specified item;falseotherwise.
See Also
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.
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.
Raises the hovered-item-changed event.
Parameters
- evt: HoveredItemChangedEventArgs
- The HoveredItemChangedEventArgs 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.
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.uninstallForces a reevaluation of the item that the pointer is currently hovering over or at a specific location.
Parameters
- location?: Point
- The query location. If omitted, the last location is queried again.
Events
Occurs when the item that is being hovered over with the pointer changes.
Properties of
HoveredItemChangedEventArgs- context: IInputModeContext
- Gets the context for the current event.
- item: IModelItem
- Gets the item that is currently hovered or
nullif no item is hovered. - oldItem: IModelItem
- Gets or sets the item that was previously hovered, possibly
null.
Examples
null. One can also configure the item types which are reported:// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
// enable the ItemHoverInputMode and let it handle edges and nodes
mode.itemHoverInputMode.enabled = true
mode.itemHoverInputMode.hoverItems =
GraphItemTypes.EDGE | GraphItemTypes.NODE
// handle changes on the hovered items
mode.itemHoverInputMode.addEventListener(
'hovered-item-changed',
(evt) => {
const oldItem = evt.oldItem
// e.g. remove the highlight from oldItem here
const newItem = evt.item
// e.g. add a highlight to newItem here
},
)