TGUI Forum

General Category => Feature requests => Topic started by: Maksat on 22 May 2020, 16:10:20

Title: Add "setMaximumTextWidth" method to RadioButtons and CheckBoxes
Post by: Maksat on 22 May 2020, 16:10:20
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:
(https://i.ibb.co/CvvgPHN/Easy-Piano-Game-2020-05-22-20-07-01-672.jpg) (https://ibb.co/y55t4QG)
Title: Re: Add "setMaximumTextWidth" method to RadioButtons and CheckBoxes
Post by: texus on 22 May 2020, 16:12:03
I'll add it to the todo list, but you could just replace the text with an actual Label widget for now.
Title: Re: Add "setMaximumTextWidth" method to RadioButtons and CheckBoxes
Post by: Maksat on 22 May 2020, 16:25:04
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
Title: Re: Add "setMaximumTextWidth" method to RadioButtons and CheckBoxes
Post by: texus on 22 May 2020, 16:26:46
That should be easily solvable by adding something like this:
label->connect("clicked", [=]{ checkBox->setChecked(!checkBox->isChecked()); });
Title: Re: Add "setMaximumTextWidth" method to RadioButtons and CheckBoxes
Post by: Maksat on 22 May 2020, 16:41:26
How I can change checkboxes texture to "TextureUncheckedHover" or "TextureCheckedHover" when mouse hovers the text?
Title: Re: Add "setMaximumTextWidth" method to RadioButtons and CheckBoxes
Post by: texus on 22 May 2020, 16:55:43
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(); });
Title: Re: Add "setMaximumTextWidth" method to RadioButtons and CheckBoxes
Post by: Maksat on 22 May 2020, 17:05:33
Got it, thank you! I will implement it like this for now and will wait until you add this future.