No more linebreaks in tooltips ?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

No more linebreaks in tooltips ?

Post by Chris_G »

Hello,
I was successfully using line breaks in tooltips before :
https://github.com/tomate44/CurvesWB/bl ... es.py#L238
tooltip_old.png
tooltip_old.png (26 KiB) Viewed 2573 times

They are now ignored :
tooltip_new.png
tooltip_new.png (24.07 KiB) Viewed 2573 times

Is there a way to get them back ?
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: No more linebreaks in tooltips ?

Post by carlopav »

Hi chris, probably my fault. New tooltips are created here: https://github.com/FreeCAD/FreeCAD/blob ... d.cpp#L855.

Current tooltip text ('ToolTip':) should not contain the command title, that is obtained through 'MenuText'.
Anyway the new function is not supposed to remove the line breaks... :cry: :roll:
follow my experiments on BIM modelling for architecture design
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: No more linebreaks in tooltips ?

Post by carlopav »

Oh, could you try to use <br> instead of \n ?
follow my experiments on BIM modelling for architecture design
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: No more linebreaks in tooltips ?

Post by Chris_G »

<br> is working, thanks.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: No more linebreaks in tooltips ?

Post by carlopav »

Great! I was lucky :)
sorry for the annoyance of having to rework your tooltips :(
follow my experiments on BIM modelling for architecture design
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: No more linebreaks in tooltips ?

Post by Chris_G »

No problem, they will be nicer like that ;)
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: No more linebreaks in tooltips ?

Post by Kunda1 »

How did i miss this thread?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: No more linebreaks in tooltips ?

Post by Roy_043 »

Changing linebreaks to "<br>" does come with some issues:

Some workbenches (TechDraw) use the tooltip texts for the statusbar texts as well. Having "<br>" instead of "\n" in the text is then a problem. In the statusbar "\n" becomes a space, but "<br>" appears as is.

If the tooltip text contains multiple spaces (for indentation) those spaces are lost when "<br>" occurs in the text. You would have to replace them with "&nbsp;".

Tooltip texts converted to "<br>" have to be re-translated.

Related:
https://forum.freecadweb.org/viewtopic.php?f=10&t=65612
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: No more linebreaks in tooltips ?

Post by TheMarkster »

Python workbenches still need to support users with the latest stable 0.19, which means this string replacement "\n" to "<br/>" has to be done, but only if the version is >= 0.20. Could be better if FreeCAD did this replacement automatically?
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: No more linebreaks in tooltips ?

Post by carlopav »

TheMarkster wrote: Wed Feb 02, 2022 3:07 am Python workbenches still need to support users with the latest stable 0.19, which means this string replacement "\n" to "<br/>" has to be done, but only if the version is >= 0.20. Could be better if FreeCAD did this replacement automatically?
I think this could be good, but i think chris_g for example already replaced his tooltips in Curves...

Roy_043 wrote: Tue Feb 01, 2022 9:26 am Changing linebreaks to "<br>" does come with some issues:

Some workbenches (TechDraw) use the tooltip texts for the statusbar texts as well. Having "<br>" instead of "\n" in the text is then a problem. In the statusbar "\n" becomes a space, but "<br>" appears as is.

If the tooltip text contains multiple spaces (for indentation) those spaces are lost when "<br>" occurs in the text. You would have to replace them with " ".

Tooltip texts converted to "<br>" have to be re-translated.

Related:
https://forum.freecadweb.org/viewtopic.php?f=10&t=65612
I Guess this is all mainly caused because i used the <h3> formatting of the header of the tooltips. It looks good, but perhaps this Is a change that can be reverted without a big loss
follow my experiments on BIM modelling for architecture design
Post Reply