Add "setMaximumTextWidth" method to RadioButtons and CheckBoxes

Started by Maksat, 22 May 2020, 16:10:20

Maksat

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

I'll add it to the todo list, but you could just replace the text with an actual Label widget for now.

Maksat

Quote from: texus on 22 May 2020, 16:12:03
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

That should be easily solvable by adding something like this:
Code (cpp) Select
label->connect("clicked", [=]{ checkBox->setChecked(!checkBox->isChecked()); });

Maksat

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

texus

Officially that currently isn't supported.
You could get it to work by faking a mouse event though:
Code (cpp) Select
label->connect("MouseEntered", [=]{ checkBox->mouseMoved(checkBox->getPosition()); });
label->connect("MouseLeft", [=]{ checkBox->mouseNoLongerOnWidget(); });

Maksat

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