Tooltips

Hover text displayed over elements

Tooltips are pieces of text or elements that appear when you hover over something.

Tooltips have a variety of options to tweak how they work and also a variety of ways they can be applied to an element.

Setting tooltips in XML

To make an element into a tooltip, you only need to set the role attribute to have the tooltip value.

<div>
  This is some text.
    
  <tooltip role="tooltip">
    This is hover text.
  </tooltip>
</div>

Setting Tooltips in Java

Setting tooltips with Delphi’s API is even simpler, you only need to call a single method:

Element element = // ...
Element tooltip = // ...

element.setTitleNode(tooltip);

Tooltip options

The following options are attributes placed on the tooltip element itself to control how it acts.

tooltip-delay

Delay for when the tooltip appears.

Supports the following units:

  • ms, millis or milliseconds
  • s or seconds
  • t or ticks

Example:

<div>
  Hello, world!
    
  <tooltip role="tooltip" tooltip-delay="250ms">
    Hover text
  </tooltip>
</div>

tooltip-behaviour

Determines how the tooltip is located when spawned.

ValueDescription
cursor-stickyFollows the cursor
cursorSpawns where the cursor is, but does not follow it
leftSpawns on the left side of the element
rightSpawns on the right side of the element
topSpawns on top of the element
bottomSpawns below the element

Example:

<div>
  Hello, world!
    
  <tooltip role="tooltip" tooltip-behaviour="cursor">
    Hover text
  </tooltip>
</div>