public class Tooltip extends Object
By default you can set text to show as a tooltip by using
Widget.setTooltipText(java.lang.String)
and
Widget.setTooltipMarkup(java.lang.String)
. However that is for
basic text and only text. If you want more then that you can hookup your
own tooltip query handler which in turn will provide an object of this
class for you to use.
In order to get an object of this class you first have to connect a queryTooltip Handler.
// any widget will do widget = new Button(); widget.connect(new Widget.queryTooltip() { @Override public boolean onQueryTooltip(Widget source, int x, int y, boolean keyboardMode, Tooltip tooltip) { // setup your tooltip. } });
Inside the method you can create your tooltip. You also receive the X and Y
values at which you can determine whether to show the tooltip or not. Which
is needed for example a TreeView which has a method to help you with. See
TreeView.hasTooltipContext(int, int, boolean)
for more information
on how a TreeView handles tooltips.
KeyboardMode indicates that the application is run by only the keyboard and no mouse.
When you want to show your tooltip return true, otherwise false.
There are two modes of displaying your tooltip contents. The first is the basic Icon and String. You can set this up in anyway you want. Please do note that both are on the same line and that the icon will always be on the left.
If you want something more fancy or display more information you set any widget to show. Suggested is a container of course. Where you have full freedom to place all your tooltip contents.
Modifier and Type | Method and Description |
---|---|
void |
setCustomWidget(Widget widget)
The widget to display in the tooltip.
|
void |
setIcon(Pixbuf icon)
The icon to display in your tooltip.
|
void |
setMarkup(String markup)
The text in pango markup to display in the tooltip.
|
void |
setStockIcon(Stock stock,
IconSize size)
The stock icon with the requested size to display in the tooltip.
|
void |
setText(String text)
The text to display in the tooltip.
|
public void setCustomWidget(Widget widget)
Grid
are
recommended.public void setIcon(Pixbuf icon)
public void setMarkup(String markup)
public void setStockIcon(Stock stock, IconSize size)
public void setText(String text)