Tree.java: correctly escape & in default Tooltip#801
Conversation
|
This bug might also exist in GTK- or Cocoa-based implementations. I suspect that they have similar fixes. |
|
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. |
b78e8db to
925be9e
Compare
|
@Phillipus Escaping the |
Yeah, I can see the problem. It's just that when I look at the Is this also happening on Mac and Linux? Edit - it's OK on Mac. |
925be9e to
18a56fc
Compare
18a56fc to
340306e
Compare
340306e to
6bb3b57
Compare
|
I came across this again and again and always thought about alternative solutions but found that it's probably the best and most central place where we can escape the string. @Phillipus do you still have any concerns or should we merge this? |
It only works for the tooltip in the first column of a Tree that uses columns. So that needs to be addressed. |
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.
38b1e26 to
9fa60ff
Compare
|
fwiw, I used the snippet below for testing. public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Tree t = new Tree (shell, 0);
t.setHeaderVisible(true);
t.setLinesVisible(true);
TreeColumn col1 = new TreeColumn(t, 0);
col1.setWidth(30);
col1.setMoveable(true);
TreeColumn col2 = new TreeColumn(t, 0);
col2.setWidth(30);
col2.setMoveable(true);
new TreeItem (t, 0).setText(new String [] {"A & B", "C & D"});
new TreeItem (t, 1).setText(new String [] {"E & F", "G & H"});
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
} |
Fix for
eclipse-platform/eclipse.platform.ui#238
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 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.