documentationfor yFiles for HTML 3.0.0.3

ToolTipInputMode

An IInputMode that detects when the mouse hovers over the CanvasComponent and displays a tooltip.

Inheritance Hierarchy
ToolTipInputMode
Implemented Interfaces

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.

Getting the ToolTipInputMode from its parent input mode
const toolTipInputMode = mode.toolTipInputMode

It 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
  }
})

Related Reading in the Developer's Guide

The CSS styling options for the tooltip are presented in detail in the section CSS Styling of the Tooltip Element .

Type Details

yFiles module
view

Constructors

Properties

Methods

Events