Add "setMaximumTextWidth" method to RadioButtons and CheckBoxes

  • 6 Replies
  • 473 Views
Hello!
I'm drawing radio buttons and check boxes to scrollable panel with fixed width (scrollablePanel.setHorizontalScrollbarPolicy(tgui::Scrollbar::Policy::Never)). Some of them have long texts and go beyond the borders of the panel. I think it would be useful to add the ability to automatically change the width of the text like in Label.
Here is example of what I have:

*

texus

  • *****
  • 1590
    • View Profile
    • Texus's Blog
I'll add it to the todo list, but you could just replace the text with an actual Label widget for now.

but you could just replace the text with an actual Label widget for now.

I did so, but the checkbox texture no longer responds to mouse actions on text

*

texus

  • *****
  • 1590
    • View Profile
    • Texus's Blog
That should be easily solvable by adding something like this:
label->connect("clicked", [=]{ checkBox->setChecked(!checkBox->isChecked()); });

How I can change checkboxes texture to "TextureUncheckedHover" or "TextureCheckedHover" when mouse hovers the text?

*

texus

  • *****
  • 1590
    • View Profile
    • Texus's Blog
Officially that currently isn't supported.
You could get it to work by faking a mouse event though:
label->connect("MouseEntered", [=]{ checkBox->mouseMoved(checkBox->getPosition()); });
label->connect("MouseLeft", [=]{ checkBox->mouseNoLongerOnWidget(); });

Got it, thank you! I will implement it like this for now and will wait until you add this future.