MSW specific: Highlight a focused buttons
Fix for #7564 - Button in focus is not highlighted anymore in PS 2.4 (accessibility issue)
This commit is contained in:
parent
34d9fbdc35
commit
229df98386
@ -1388,24 +1388,41 @@ void GUI_App::update_label_colours()
|
|||||||
tab->update_label_colours();
|
tab->update_label_colours();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_focused(HWND hWnd)
|
||||||
|
{
|
||||||
|
HWND hFocusedWnd = ::GetFocus();
|
||||||
|
return hFocusedWnd && hWnd == hFocusedWnd;
|
||||||
|
}
|
||||||
|
|
||||||
void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool just_font/* = false*/)
|
void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool just_font/* = false*/)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
bool is_focused_button = false;
|
||||||
if (wxButton* btn = dynamic_cast<wxButton*>(window)) {
|
if (wxButton* btn = dynamic_cast<wxButton*>(window)) {
|
||||||
if (!(btn->GetWindowStyle() & wxNO_BORDER)) {
|
if (!(btn->GetWindowStyle() & wxNO_BORDER)) {
|
||||||
btn->SetWindowStyle(btn->GetWindowStyle() | wxNO_BORDER);
|
btn->SetWindowStyle(btn->GetWindowStyle() | wxNO_BORDER);
|
||||||
highlited = true;
|
highlited = true;
|
||||||
}
|
}
|
||||||
// hovering for buttons
|
// button marking
|
||||||
{
|
{
|
||||||
auto focus_button = [this, btn](const bool focus) {
|
auto mark_button = [this, btn, highlited](const bool mark) {
|
||||||
btn->SetForegroundColour(focus ? m_color_hovered_btn_label : m_color_label_default);
|
if (btn->GetLabel().IsEmpty())
|
||||||
|
btn->SetBackgroundColour(mark ? m_color_selected_btn_bg : highlited ? m_color_highlight_default : m_color_window_default);
|
||||||
|
else
|
||||||
|
btn->SetForegroundColour(mark ? m_color_hovered_btn_label : m_color_label_default);
|
||||||
btn->Refresh();
|
btn->Refresh();
|
||||||
btn->Update();
|
btn->Update();
|
||||||
};
|
};
|
||||||
|
|
||||||
btn->Bind(wxEVT_ENTER_WINDOW, [focus_button](wxMouseEvent& event) { focus_button(true); event.Skip(); });
|
// hovering
|
||||||
btn->Bind(wxEVT_LEAVE_WINDOW, [focus_button](wxMouseEvent& event) { focus_button(false); event.Skip(); });
|
btn->Bind(wxEVT_ENTER_WINDOW, [mark_button](wxMouseEvent& event) { mark_button(true); event.Skip(); });
|
||||||
|
btn->Bind(wxEVT_LEAVE_WINDOW, [mark_button, btn](wxMouseEvent& event) { mark_button(is_focused(btn->GetHWND())); event.Skip(); });
|
||||||
|
// focusing
|
||||||
|
btn->Bind(wxEVT_SET_FOCUS, [mark_button](wxFocusEvent& event) { mark_button(true); event.Skip(); });
|
||||||
|
btn->Bind(wxEVT_KILL_FOCUS, [mark_button](wxFocusEvent& event) { mark_button(false); event.Skip(); });
|
||||||
|
|
||||||
|
if (is_focused_button = is_focused(btn->GetHWND()))
|
||||||
|
mark_button(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (wxTextCtrl* text = dynamic_cast<wxTextCtrl*>(window)) {
|
else if (wxTextCtrl* text = dynamic_cast<wxTextCtrl*>(window)) {
|
||||||
@ -1427,7 +1444,8 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju
|
|||||||
|
|
||||||
if (!just_font)
|
if (!just_font)
|
||||||
window->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
|
window->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
|
||||||
window->SetForegroundColour(m_color_label_default);
|
if (!is_focused_button)
|
||||||
|
window->SetForegroundColour(m_color_label_default);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user