Repository navigation
[Win32] Show the hovered column in a reordered Tree's cell tooltip - #3923
Merged
HeikoKlare merged 1 commit intoDec 4, 2026
Merged
HeikoKlare merged 1 commit into
HeikoKlare merged 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the Win32 Tree tooltip column-reordering fix.
No open issues 🎉
What changed in this PR
Fixes Win32 Tree cell tooltips after column reordering so their content and owner-draw event indices match the hovered cell.
Changes:
- Makes cell lookup return the column’s creation-order index rather than its display position.
- Updates tooltip consumers and preserves image spacing and grid offsets for the first displayed column.
- Adds regression tests for default and reordered columns.
| File | Description |
|---|---|
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java |
Corrects column identity throughout tooltip lookup and rendering. |
bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/TreeWin32Tests.java |
Tests tooltip column resolution with default and reordered column layouts. |
Review effort: Balanced
HeikoKlare
marked this pull request as ready for review
December 1, 2026 17:30
When the columns of an owner-drawn Tree are reordered, hovering a cell
whose content does not fit shows a tool tip with a different column's
content: its text, image and alignment are taken from the column that
was created at the hovered display position, not from the column that is
displayed there, and an EraseItem or PaintItem listener drawing into the
tool tip is handed that wrong column as well. Hovering the leading cell
of a tree whose column order is {1, 0} therefore shows the text of
column 0 while the cell under the pointer belongs to column 1.
The tool tip now shows the content of the cell the pointer is on, and
the item events report the column it belongs to.
The cell lookup walks the columns in display order and already resolved
the column behind each position to read the item's font, bounds and
measured size, but reported the position to its callers. It now reports
that resolved column, which also makes the mapping that the text tool
tip applied on its own redundant. The two places that single out the
leading cell, where the tree image sits and where no grid line precedes
the text, ask for the first displayed column instead of relying on the
position.
The tool tip's text is still painted with the control font rather than
the cell font, which is a separate, pre-existing defect.
Assisted-by: Claude Opus 5 <noreply@anthropic.com>
HeikoKlare
force-pushed
the
win32-tree-custom-tooltip-column-order
branch
from
December 4, 2026 11:57
d45cf72 to
1fe731a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & Why
When the columns of an owner-drawn
Treeare reordered, throughTree.setColumnOrderor by the user dragging a column thatTreeColumn.setMoveable(true)made movable, its cell tool tip shows the wrong cell. Hovering a cell whose content does not fit, the tool tip appears over the right cell and in the right size, but its text, image and alignment come from the column that was created at that display position rather than from the column displayed there. For a tree with the column order{1, 0}, hovering the leading cell shows the text of column 0 while the cell under the pointer belongs to column 1. AnEraseItemorPaintItemlistener that draws into the tool tip is handed that same wrong column, so custom-drawn cells are affected too.With this change the tool tip shows the content of the cell the pointer is on, and the item events report the column that cell belongs to.
The cell lookup behind the tool tip walks the columns in display order and already resolved the column behind each position to read the item's font, bounds and measured size, but it reported the mere position to its callers. It now reports the resolved column, which also makes the mapping that the text tool tip applied on its own (added in c17e30b) redundant, so there is one convention again. The two places that single out the leading cell, where the tree's image sits and where no grid line precedes the text, now ask for the first displayed column instead of relying on the position being zero.
The tool tip's text is still painted with the control font rather than with the cell font. That is a separate, pre-existing defect, fixed in #3919 and deliberately left out here.
How to test
The test shows that the cell tool tip of a reordered tree no longer shows a different column's content.
Prerequisites: Windows, SWT built from this branch.
Treethat has anSWT.MeasureItemlistener and nosetToolTipText, three columns narrow enough to truncate their texts, clearly distinct cell texts, andtree.setColumnOrder(new int[] {2, 0, 1}).tree.setLinesVisible(true)and aSWT.RIGHTcolumn: without the change the tool tip of the leading cell also reserves the image slot of, and uses the alignment of, the wrong column; with the change both follow the hovered cell.setColumnOrdercall and repeat: the tool tips are correct before and after the change, which is the unchanged behaviour.Verified by hand at 100% zoom in the light theme. Fractional zoom and the dark theme are unverified.
TreeWin32Tests.test_cellToolTipBelongsToTheColumnInReorderedColumnspins the column the lookup resolves; it fails without the change withexpected: <0> but was: <1>.Screenshots
One image, at 100% zoom in the light theme, of a two-column owner-drawn tree with the column order
{1, 0}, hovering the leading cell, which is column "one": without the fix the tool tip reads "ZeroZeroZeroZer...", with the fix it reads "OneOneOneOne".🤖 Generated with Claude Code