Opened 6 years ago

Closed 3 months ago

Last modified 3 months ago

#4685 closed defect (fixed)

wxMSW: text layout bug in SetToolTip()

Reported by: jianliang79 Owned by:
Priority: normal Milestone:
Component: wxMSW Version: dev-latest
Keywords: wxTooltip SetTip width Cc: jianliang79
Blocked By: Blocking:
Patch: yes

Description

dear developers:

In wxMSW, when I set a tooltip by calling SetToolTip() method the following function will be called to add this tooltip:
void wxToolTip::Add(WXHWND hWnd)
If the tooltip string conatins '\n', it will send TTM_SETMAXTIPWIDTH message to the window to make the string display as multiline.
The problem is : if I have called SetToolTip() with a string contains '\n', the maximum tip width will be set to a specific value, the next time I call SetToolTip() with a string without '\n' to the same window, the tooltip will still be displayed as multiline if the latter's width is greater than the maximum tip width set through TTM_SETMAXTIPWIDTH message.

Attachments (2)

tooltip.png download (7.2 KB) - added by awi 3 months ago.
How tooltips are displayed.
tooltip.patch download (6.6 KB) - added by awi 3 months ago.
Patch to modify wxToolTip (width adjustement).

Download all attachments as: .zip

Change History (5)

Changed 3 months ago by awi

How tooltips are displayed.

Changed 3 months ago by awi

Patch to modify wxToolTip (width adjustement).

comment:1 Changed 3 months ago by awi

  • Keywords wxTooltip SetTip width added
  • Patch set
  • Version set to dev-latest

Indeed, tooltip width is determined once, when the first tooltip is created (based on the longest line length, if it is multi-line). If next tooltip text is longer then the initial one then it is wrapped because tooltip width is not adjusted (see attached screenshots).
The issue can be observed in the 'widgets' sample.

Attached patch modifies the code in a way that instructions to set tooltip width are relocated to the separate procedure and this procedure is called when the tooltip is created and when its text is changed.

comment:2 Changed 3 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [75756]) Recompute the tooltip width when changing its text in wxMSW.

This avoids unnecessarily wrapping the tooltips if they are set to a longer
string than their initial value later.

Closes #4685.

comment:3 Changed 3 months ago by VZ

(In [75758]) Recompute the tooltip width when changing its text in wxMSW.

This avoids unnecessarily wrapping the tooltips if they are set to a longer
string than their initial value later.

Closes #4685.

Note: See TracTickets for help on using tickets.