Skip to content

Conversation

@Wittmaxi
Copy link

@Wittmaxi Wittmaxi commented Sep 5, 2023

Fix for
eclipse-platform/eclipse.platform.ui#238
eclipse-platform/eclipse.platform.ui#1075

grafik

When TreeColumn's are too small, a ToolTip is displayed on hover to reveal the whole Label of an Item (The WIN32-Docs call them In-Place Tooltips).
These ToolTips pass through the Composite-ToolTipText-generator which escapes all & in a Text - allowing to reuse Text from Buttons as Tooltips. This is a well documented Feature of setToolTipText. Since TreeItem's Label does not have Mnemonics, we do not assume that the & should require escaping by the User.

This Commit Escapes all & in default Tooltips that are handled by the default mechanism.

@Wittmaxi
Copy link
Author

Wittmaxi commented Sep 5, 2023

I am not sure wether using RegExes is an okay thing to do here.
I do not expect this method to be called a lot, hence why I am okay sacrificing a bit of Performance for better code clarity.

This bug might also exist in GTK- or Cocoa-based implementations. I suspect that they have similar fixes.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2023

Test Results

   546 files  ±0     546 suites  ±0   28m 45s ⏱️ - 1m 12s
 4 412 tests ±0   4 395 ✅ ±0   17 💤 ±0  0 ❌ ±0 
16 718 runs  ±0  16 591 ✅ ±0  127 💤 ±0  0 ❌ ±0 

Results for commit 340306e. ± Comparison against base commit fc94eaf.

♻️ This comment has been updated with latest results.

@Phillipus
Copy link
Contributor

Is that the right place to be changing the contents of the tooltip string? Something tells me that it's not, and perhaps ampersand escaping should be done further up the stack, or by the client.

@Wittmaxi Wittmaxi force-pushed the MW_TreeColumnToolTip branch from b78e8db to 925be9e Compare September 5, 2023 13:21
@Wittmaxi
Copy link
Author

Wittmaxi commented Sep 5, 2023

@Phillipus Escaping the & definitely can't be done by the client since this ToolTip is automatically generated from the Text. I also don't think explicitly setting a ToolTip is a good idea since this ToolTip is only shown when the TreeColumn is too small - property that is checked for before drawing the ToolTip

@Phillipus
Copy link
Contributor

Phillipus commented Sep 5, 2023

@Phillipus Escaping the & definitely can't be done by the client since this ToolTip is automatically generated from the Text. I also don't think explicitly setting a ToolTip is a good idea since this ToolTip is only shown when the TreeColumn is too small - property that is checked for before drawing the ToolTip

Yeah, I can see the problem. It's just that when I look at the String toolTipText (NMTTDISPINFO hdr) code it seems to me to be the wrong place to actually change the string. But maybe there is no other place to change it.

Is this also happening on Mac and Linux? Edit - it's OK on Mac.

@Wittmaxi Wittmaxi force-pushed the MW_TreeColumnToolTip branch from 925be9e to 18a56fc Compare September 6, 2023 09:14
This fixes eclipse-platform/eclipse.platform.ui#1075

When TreeColumn's are too small, a ToolTip is displayed on hover to
reveal the whole Label of an Item (The WIN32-Docs call them 'Inline
ToolTips').
These ToolTips pass through the Composite-ToolTipText-generator which
escapes all & in a Text - allowing to reuse Text from Buttons as
Tooltips. This is a well documented Feature of setToolTipText.
Since TreeItem's Label does not have Mnemonics, we do not assume that the
& needs escaping.

This Commit Escapes all & in default Tooltips that are handled by the
default mechanism.
@akurtakov akurtakov force-pushed the MW_TreeColumnToolTip branch from 18a56fc to 340306e Compare July 29, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants