mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:57:35 +00:00
WindowServer: Don't keep menu items in hovered state after the cursor leaves.
This commit is contained in:
parent
6dd1a1f26d
commit
e6de6c4f45
3 changed files with 16 additions and 2 deletions
|
@ -114,12 +114,19 @@ void WSMenu::on_window_message(WSMessage& message)
|
|||
if (!m_hovered_item)
|
||||
return;
|
||||
did_activate(*m_hovered_item);
|
||||
m_hovered_item = nullptr;
|
||||
redraw();
|
||||
clear_hovered_item();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void WSMenu::clear_hovered_item()
|
||||
{
|
||||
if (!m_hovered_item)
|
||||
return;
|
||||
m_hovered_item = nullptr;
|
||||
redraw();
|
||||
}
|
||||
|
||||
void WSMenu::did_activate(WSMenuItem& item)
|
||||
{
|
||||
if (on_item_activation)
|
||||
|
|
|
@ -57,6 +57,9 @@ public:
|
|||
WSMenuItem* item_at(const Point&);
|
||||
void redraw();
|
||||
|
||||
const WSMenuItem* hovered_item() const { return m_hovered_item; }
|
||||
void clear_hovered_item();
|
||||
|
||||
Function<void(WSMenuItem&)> on_item_activation;
|
||||
|
||||
private:
|
||||
|
|
|
@ -485,6 +485,10 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_current_menu && m_current_menu->hovered_item() && !m_current_menu->menu_window()->rect().contains(event.position())) {
|
||||
m_current_menu->clear_hovered_item();
|
||||
}
|
||||
|
||||
// FIXME: Figure out an automatic menu dismissal logic that feels right.
|
||||
#if 0
|
||||
if (m_current_menu && event.type() == WSMouseEvent::MouseUp && event.button() == MouseButton::Left)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue