- I
Remarks
In order to make use of this instance one has to register with the query-tool-tip event. Setting a custom validHoverLocationHitTestable will restrict the area where a tooltip can be shown.
This mode is exclusive by default.
The tooltip HTML element is positioned using "position: absolute". It is therefore positioned with respect to it's offset parent, which is the closest ancestor with "position: relative". In summary, for the tooltip to work properly, the element containing the graph component must be styled with "position: relative".
The tooltip element is using the yfiles-tooltip CSS class and provides additional classes for the enter and leave phase of the element.
Examples
Typically the ToolTipInputMode is installed as child mode of a GraphEditorInputMode or GraphViewerInputMode and can be retrieved from the toolTipInputMode property.
const toolTipInputMode = mode.toolTipInputModeIt is recommended to configure the tooltip handling on the parent GraphEditorInputMode or GraphViewerInputMode instead of the ToolTipInputMode. This involves registering for the query-item-tool-tip event instead of the query-tool-tip event:
// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.toolTipItems = GraphItemTypes.NODE
// register a listener
mode.addEventListener('query-item-tool-tip', (evt) => {
if (evt.handled) {
// A tooltip has already been assigned -> nothing to do.
return
}
// We can safely cast here because we set ToolTipItems to only Node.
const hitNode = evt.item as INode
if (hitNode.labels.size > 0) {
// Show the text of the first label as tooltip.
evt.toolTip = hitNode.labels.get(0).text
// Indicate that the tooltip content has been set.
evt.handled = true
}
})See Also
- The CSS styling options for the tooltip are presented in detail in the section CSS Styling of the Tooltip Element .
Developer's Guide
Members
Constructors
Properties
Gets the installed controller.
Gets or sets the duration the mouse has to hover in one place to show a tooltip.
Gets or sets the duration to show the tooltip.
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 amount the mouse pointer has to move in order to hide the tooltip.
(10, 10).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 the tooltip location offset in view coordinates.
Examples
// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.toolTipInputMode.toolTipLocationOffset = new Point(20, 20)See Also
Gets or sets a custom parent element to which the tooltip is added as a child in the DOM.
By default this property is null, which means that the tooltip is added to the document.body.
When specifying some other element as parent, it must be assured that the element is currently visible (i.e. has no style with property display: none).
Gets or sets the cursor to use when the mouse is at a valid hover location.
nullGets or sets an IHitTestable that determines where the mouse may hover and a tooltip can be shown.
Methods
Parameters
- originalPosition: Point
- The calculated tooltip position relative to the document root
Return Value
- Point
- The adjusted tooltip location relative to the document root
See Also
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 query-tool-tip event for the upcoming text query operation.
Factory method that creates the tooltip.
Parameters
- location: Point
- The position in world coordinates.
Return Value
- Point
- The position in view coordinates.
See Also
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.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.
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 query-tool-tip event.
Parameters
- evt: QueryToolTipEventArgs
- The QueryToolTipEventArgs instance containing the event data.
See Also
Developer's Guide
content is null, this method will call getToolTipContent to query the content. If there is any content it will display the tooltip at the location returned by getToolTipLocation.Parameters
- location: Point
- The coordinates where the mouse is hovering to trigger this function.
- content?: any
- The content to display in the tooltip. The default value is
null.
Return Value
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.
Parameters
- location: Point
- The location in the world coordinate system.
- content?: any
- The content of the tooltip. If
null, getToolTipContent will be called to get the content.
Return Value
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 this mode queries the tooltip for a certain query location.
Properties of
QueryToolTipEventArgs- context: IInputModeContext
- Gets the context for the current event.
- handled: booleanwritable
- Gets or sets a value indicating whether this QueryToolTipEventArgs has been handled.
- queryLocation: Point
- Gets the query location in world coordinates.
- toolTip: anywritable
- Gets or sets the tooltip content to use.
Examples
ToolTipInputMode. This involves registering for the query-item-tool-tip event instead of this event:// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.toolTipItems = GraphItemTypes.NODE
// register a listener
mode.addEventListener('query-item-tool-tip', (evt) => {
if (evt.handled) {
// A tooltip has already been assigned -> nothing to do.
return
}
// We can safely cast here because we set ToolTipItems to only Node.
const hitNode = evt.item as INode
if (hitNode.labels.size > 0) {
// Show the text of the first label as tooltip.
evt.toolTip = hitNode.labels.get(0).text
// Indicate that the tooltip content has been set.
evt.handled = true
}
})See Also
Developer's Guide