documentationfor yFiles for HTML 2.6

MouseHoverInputMode

An IInputMode that detects when the mouse hovers over the CanvasComponent.

Inheritance Hierarchy
MouseHoverInputMode
Implemented Interfaces

Remarks

This implementation will show a ToolTip. In order to make use of this instance one has to register with the QueryToolTip event. Setting a custom validHoverLocationHitTestable will restrict the area where a tooltip can be shown.

This mode is exclusive by default.

Examples

Typically the MouseHoverInputMode is installed as child mode of a GraphEditorInputMode or GraphViewerInputMode and can be retrieved from the mouseHoverInputMode property.

Getting the MouseHoverInputMode from its parent input mode
const mouseHoverInputMode = mode.mouseHoverInputMode

It is recommended to configure the tooltip handling on the parent GraphEditorInputMode or GraphViewerInputMode instead of the MouseHoverInputMode. This involves registering for the QueryItemToolTip event instead of the QueryToolTip event:

// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.toolTipItems = GraphItemTypes.NODE
// register a listener
mode.addQueryItemToolTipListener((src, args) => {
  if (args.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 = args.item
  if (hitNode.labels.size > 0) {
    // Show the text of the first label as tooltip.
    args.toolTip = hitNode.labels.get(0).text

    // Indicate that the tooltip content has been set.
    args.handled = true
  }
})// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.toolTipItems = GraphItemTypes.NODE
// register a listener
mode.addQueryItemToolTipListener((src, args) => {
  if (args.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 = args.item as INode
  if (hitNode.labels.size > 0) {
    // Show the text of the first label as tooltip.
    args.toolTip = hitNode.labels.get(0).text

    // Indicate that the tooltip content has been set.
    args.handled = true
  }
})

Type Details

yfiles module
view-component
yfiles-umd modules
All view modules
Legacy UMD name
yfiles.input.MouseHoverInputMode

See Also

Constructors

Properties

Methods

Events