Skip to content

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

Merged
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:win32-button-focus-rect
Sep 29, 2026
Merged

vogella merged 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.

@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

  212 files  ±0    212 suites  ±0   26m 3s ⏱️ - 3m 55s
4 969 tests ±0  4 941 ✅ ±0   28 💤 ±0  0 ❌ ±0 
7 216 runs  ±0  7 022 ✅ ±0  194 💤 ±0  0 ❌ ±0 

Results for commit 582a376. ± Comparison against base commit a04b0b7.

♻️ This comment has been updated with latest results.

@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?

@vogella

vogella commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Gray

compare-gray

Blue
compare-blue

Before:

before-blue before-gray

After:

after-blue after-gray

@vogella
vogella marked this pull request as ready for review September 28, 2026 09:15
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 c2a5e69 to 582a376 Compare September 28, 2026 09:15
@vogella
vogella merged commit 624254c into eclipse-platform:master Sep 29, 2026
22 checks passed
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