White button text on dark background colour unreadable on mouseover

16 views
Skip to first unread message

Kenneth Porter

unread,
Aug 7, 2022, 8:30:23 PM8/7/22
to wx-u...@googlegroups.com
On Windows 10. I've got a button with background colour set to blue and
foreground to white. When I mouseover to click it, the button turns white
text on very light grey background. I'm guessing this is normal Windows
behaviour. What must I do to keep the button readable on mouseover? Perhaps
set a special mouseover color to a slightly lighter blue?

Vadim Zeitlin

unread,
Aug 14, 2022, 11:24:34 AM8/14/22
to wx-u...@googlegroups.com
On Sun, 07 Aug 2022 17:30:16 -0700 Kenneth Porter wrote:

KP> On Windows 10. I've got a button with background colour set to blue and
KP> foreground to white. When I mouseover to click it, the button turns white
KP> text on very light grey background. I'm guessing this is normal Windows
KP> behaviour. What must I do to keep the button readable on mouseover? Perhaps
KP> set a special mouseover color to a slightly lighter blue?

This would be ideal, but I don't think we support this. In fact, looking
at the code, we seem to explicitly avoid changing the background colour in
the "hot" state (see the check for PBS_HOT in src/msw/anybutton.cpp).

We could add some MSW-specific MSWSetHotBackgroundColour() and use the
colour passed to it here, but it would arguably be better to just avoid
modifying the foreground colour in the hot state as well and use the
standard one as well. This is not ideal, as the button would basically lose
its custom appearance, but still better than making it completely
unreadable.

Please don't hesitate to make a PR (which should be relatively
straightforward) if this would be useful for you, but if not, please open
an issue for this as I don't think we have one yet (but please search for
it before opening just in case I forgot).

Thanks,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Kenneth Porter

unread,
Aug 14, 2022, 9:36:14 PM8/14/22
to wx-u...@googlegroups.com
--On Sunday, August 14, 2022 6:24 PM +0200 Vadim Zeitlin
<va...@wxwidgets.org> wrote:

> We could add some MSW-specific MSWSetHotBackgroundColour() and use the
> colour passed to it here, but it would arguably be better to just avoid
> modifying the foreground colour in the hot state as well and use the
> standard one as well. This is not ideal, as the button would basically
> lose its custom appearance, but still better than making it completely
> unreadable.

This sounds promising.

> Please don't hesitate to make a PR (which should be relatively
> straightforward) if this would be useful for you, but if not, please open
> an issue for this as I don't think we have one yet (but please search for
> it before opening just in case I forgot).

I couldn't find anything applicable so started this one:

<https://github.com/wxWidgets/wxWidgets/issues/22721>



Reply all
Reply to author
Forward
0 new messages