Skip to content

[Win32] Show the hovered column in a reordered Tree's cell tooltip - #3923

Merged
HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
HeikoKlare:win32-tree-custom-tooltip-column-order
Dec 4, 2026
Merged

HeikoKlare merged 1 commit into
eclipse-platform:masterfrom
HeikoKlare:win32-tree-custom-tooltip-column-order

Conversation

@HeikoKlare

@HeikoKlare HeikoKlare commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What & Why

When the columns of an owner-drawn Tree are reordered, through Tree.setColumnOrder or by the user dragging a column that TreeColumn.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. An EraseItem or PaintItem listener 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.

  1. Run an SWT application with a Tree that has an SWT.MeasureItem listener and no setToolTipText, three columns narrow enough to truncate their texts, clearly distinct cell texts, and tree.setColumnOrder(new int[] {2, 0, 1}).
  2. Hover each cell and compare the tool tip with the cell under the pointer.
    • Without the change: each tool tip shows the text of another column, the one created at the hovered display position.
    • With the change: each tool tip shows the text of the cell under the pointer.
  3. Repeat with an image on one cell, tree.setLinesVisible(true) and a SWT.RIGHT column: 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.
  4. Remove the setColumnOrder call 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_cellToolTipBelongsToTheColumnInReorderedColumns pins the column the lookup resolves; it fails without the change with expected: <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".

image

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Test Results (win32)

  185 files  ±0    185 suites  ±0   19m 36s ⏱️ + 3m 29s
5 351 tests +2  5 258 ✅ +2   93 💤 ±0  0 ❌ ±0 
5 569 runs  +4  5 284 ✅ +2  285 💤 +2  0 ❌ ±0 

Results for commit 1fe731a. ± Comparison against base commit 66873f7.

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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
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
HeikoKlare force-pushed the win32-tree-custom-tooltip-column-order branch from d45cf72 to 1fe731a Compare December 4, 2026 11:57
@HeikoKlare
HeikoKlare merged commit f8dc85e into eclipse-platform:master Dec 4, 2026
16 checks passed
@HeikoKlare
HeikoKlare deleted the win32-tree-custom-tooltip-column-order branch December 4, 2026 12:26
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.

2 participants