Skip to content

[win32] Do not invert the pixels for the Button focus rectangle - #3543

Draft
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:win32-button-focus-rect
Draft

[win32] Do not invert the pixels for the Button focus rectangle#3543
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:win32-button-focus-rect

Conversation

@vogella

@vogella vogella commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

When a Button has a custom foreground, SWT paints the button content itself and therefore also paints the focus indication. It used DrawFocusRect(), which XOR-inverts the pixels below it, so the focus rectangle takes on whatever the complement of the background happens to be. On a button styled with background #0071BC and white text the rectangle came out as #FF8E43, and on a mid-gray background it is close to invisible, which makes the focus indicator unreliable.

The rectangle is now drawn with a dotted pen in the foreground color, the same color the button label uses, so it is legible on whatever surface the label is legible on. The rectangle geometry, the background fill and the path where only a background is set are unchanged, so unstyled buttons and the default Eclipse theme look exactly as before.

Snippet395 demonstrates the case. This is win32-only code and I could only compile it on Linux, so a visual check on Windows 11 is still needed, which is why this is a draft.

With a custom foreground SWT paints the button content itself, and drew
the focus rectangle with DrawFocusRect(), which XOR-inverts the pixels
below it. On background #0071BC that gave a #FF8E43 rectangle, on
mid-gray it was invisible. Use a dotted pen in the foreground color
instead, the color the button text already uses. Geometry is unchanged.

Adds Snippet395.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

  212 files  +   36    212 suites  +36   30m 16s ⏱️ + 5m 15s
4 898 tests ±    0  4 874 ✅ ±    0   24 💤 ± 0  0 ❌ ±0 
7 074 runs  +1 137  6 906 ✅ +1 119  168 💤 +18  0 ❌ ±0 

Results for commit 43a1b6e. ± Comparison against base commit 3e3b24b.

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.

1 participant