Tooltips
« on: 07 September 2014, 02:12:30 »
Do we have this yet? It doesn't seem like we do. The only post I found with search was a year or so old and said you would probably add it later. Tooltips are essentially mandatory for games.

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Tooltips
« Reply #1 on: 07 September 2014, 11:29:37 »
No, not yet. I will add them on my todo list for v0.7.

I guess I will end up implementing it like this:
Code: [Select]
auto tooltip = tgui::ToolTip::create("Black.conf");
tooltip->setText("Hello world");
picture->setToolTipText(tooltip);

For normal widgets the last line would have been gui.add(widget), but since tooltips are not supposed to be in the gui but connected to a widget I will have to give every widget such a setToolTipText function.


I always delayed tool tips for a different reason as well. Having custom tool tips is one thing, but having them integrate nicely with the gui is another. With just a simple setText function it would seem impossible to make the tooltip display e.g. the item of the listbox below your mouse.
But I learned some really cool c++11 stuff yesterday. So if I would add a function that returns the item below the mouse then you could type:
Code: [Select]
tooltip->setText(std::bind(&tgui::ListBox::getHoveredItem, listBox));
So that solves the limitation that I always thought I would have.

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Tooltips
« Reply #2 on: 09 September 2014, 02:26:10 »
The Tooltip widget has been added to v0.7-dev.

When using the built-in white theme, you only need to set the text.
Code: [Select]
button->getTooltip()->setText("Hello world");
Otherwise you must load the theme file first.
Code: [Select]
button->setTooltip(tgui::Tooltip::create("Black.conf"));
Edit:
But the downside of this news is that v0.7 is still far away from being released, so using v0.7-dev is not a great option unless it is just for testing, and I will not port the Tooltip widget to v0.6.
« Last Edit: 09 September 2014, 02:30:38 by texus »