Tooltips

Paweł Pastuszak edited this page Jun 26, 2016 · 14 revisions

Tooltips (source) are widgets that appear below other widgets after user hovers mouse pointer on that other widget. Showcase

Tooltip can be attached to any actor, only one tooltip can be attached to actor at the same time. By default tooltip appears bellow actor, however if there is not enough space bellow actor, tooltip will be displayed above it.

Tooltip has only basic constructors taking style this is because tooltips are meant to be created using TooltipBuilder.

Example, creating tooltip for VisLabel:

VisLabel labelWithTooltip = new VisLabel("label with tooltip");
new Tooltip.Builder("this label has a tooltip").target(labelWithTooltip).build();

Detaching any tooltip from actor:

Tooltip.removeTooltip(someActor)

As you can see tooltips are not part of actor (i.e. method like actor.setTooltip(...) does not exist). Tooltips works by attaching listener to target actor, if you remove that listener from actor (for example by calling actor.clearListeners()) then you have to attach tooltip again by calling tooltip.attach(), you can also remove tooltip manually by calling tooltip.detach())

Tooltip target can be changed by calling tooltip.setTarget(Actor newTarget), this will automatically detach tooltip from old target and attach it to new target.

VisImageButton

VisImageButton has constructor that allows to add tooltip alongside with button icon, for example (code from showcase):

VisImageButton exploreButton = new VisImageButton(folderIconDrawable, "Explore");
VisImageButton settingsButton = new VisImageButton(settingsIconDrawable, "Change view");
VisImageButton importButton = new VisImageButton(importIconDrawable, "Import");
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.