1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:47:37 +00:00

LibGUI: Fixes Widget->set_visible(false) still maintains focus bug

When setting a Widget->set_visible(false), if that Widget->has_focus()
it will continue to have focus, even though it's not visible to the user
anymore.

Now calling Widget->set_visible(false) will remove focus from the Widget
if it had focus, and the Window will give focus back to the Widget
that had it previously, if there was one.
This commit is contained in:
Matthew Jones 2021-06-01 22:08:47 -06:00 committed by Andreas Kling
parent 9720261540
commit 123848f0c1
3 changed files with 8 additions and 0 deletions

View file

@ -726,6 +726,8 @@ void Widget::set_visible(bool visible)
parent->invalidate_layout();
if (m_visible)
update();
if (!m_visible && is_focused())
set_focus(false);
if (m_visible) {
ShowEvent e;