wxMac, DrawItemSelectionRect in dark mode

32 views
Skip to first unread message

Robert Roebling

unread,
Dec 15, 2025, 4:44:58 PM (5 days ago) Dec 15
to wx-...@googlegroups.com
Hi all,

wxRendererNative::DrawItemSelectionRect() is used e.g. by the generic
tree control and it uses this code for OSX to pick the colour:

wxColour col( wxMacCreateCGColorFromHITheme( (flags & wxCONTROL_FOCUSED)
? kThemeBrushAlternatePrimaryHighlightColor
: kThemeBrushSecondaryHighlightColor ) );

This correctly draws the selected rectangle when the control has focus
in both light and dark modes. If the app is in light mode it also
picks what looks to be an appropriate grey if the control does not
have focus. But when the control doesn't have the focus, then that
grey is too bright in dark mode. Any idea how to adapt this to dark
mode?

Robert

Stefan Csomor

unread,
Dec 16, 2025, 2:42:53 AM (4 days ago) Dec 16
to wx-...@googlegroups.com
Hi Robert
Does this also look wrong when the app has been started in dark Mode ? The reason I’m asking is because wxMacCreateCGColorFromHITheme has some caching involved. And IIRC only NSColor change their RGB values according to the current appearance, and not CGColors.

 Going to use NSColors and constructing wxColours directly from them would perhaps offer better results, the scope would have to be guarded with a     wxOSXEffectiveAppearanceSetter helper , https://developer.apple.com/documentation/appkit/ui-element-colors would give the secondarySelectedControlColor as replacement,  if also this color is not usable in dark mode then perhaps we might have to darken the resulting wxColour in dark mode.

HTH,

Stefan

Robert Roebling

unread,
Dec 16, 2025, 12:19:13 PM (4 days ago) Dec 16
to wx-...@googlegroups.com
No change when I change to dark mode before creation of the first wxFrame

Robert

Am Di., 16. Dez. 2025 um 08:42 Uhr schrieb 'Stefan Csomor' via wx-dev
<wx-...@googlegroups.com>:
> --
> You received this message because you are subscribed to the Google Groups "wx-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wx-dev+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/wx-dev/45b79a049a5940208d4fb9f7d19abfa6%40advancedconcepts.ch.

Robert Roebling

unread,
Dec 16, 2025, 12:20:47 PM (4 days ago) Dec 16
to wx-...@googlegroups.com
Maybe using
unemphasizedSelectedTextBackgroundColor
is the right approach?

Am Di., 16. Dez. 2025 um 18:18 Uhr schrieb Robert Roebling
<robert....@googlemail.com>:

Stefan Csomor

unread,
Dec 16, 2025, 12:33:06 PM (4 days ago) Dec 16
to wx-...@googlegroups.com
That would be the macOS 10.14+ Version but to support older versions,  the deprecated secondarySelectedControlColor would be the one I’d test with

Reply all
Reply to author
Forward
0 new messages