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.

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Test Results

  212 files  ±0    212 suites  ±0   28m 33s ⏱️ -52s
4 913 tests ±0  4 887 ✅ +1   26 💤 ±0  0 ❌  - 1 
7 101 runs  ±0  6 921 ✅ +1  180 💤 ±0  0 ❌  - 1 

Results for commit c2a5e69. ± Comparison against base commit 40136a0.

♻️ This comment has been updated with latest results.

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.
@vogella
vogella force-pushed the win32-button-focus-rect branch from 43a1b6e to c2a5e69 Compare August 31, 2026 15:40
@tmssngr

tmssngr commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

How the focus rect will look like - dotted or a solid line?

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