mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 06:05:02 +00:00
WindowServer: Give menu items an identifier field and add a simple callback.
Eventually these identifiers will be sent to the userspace client who created the menu. None of that is hooked up yet though.
This commit is contained in:
parent
78fc7a9ef2
commit
145aa27b8f
5 changed files with 41 additions and 9 deletions
|
@ -107,7 +107,23 @@ void WSMenu::on_window_message(WSMessage& message)
|
|||
return;
|
||||
m_hovered_item = item;
|
||||
redraw();
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.type() == WSMessage::MouseUp) {
|
||||
if (!m_hovered_item)
|
||||
return;
|
||||
did_activate(*m_hovered_item);
|
||||
m_hovered_item = nullptr;
|
||||
redraw();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void WSMenu::did_activate(WSMenuItem& item)
|
||||
{
|
||||
if (on_item_activation)
|
||||
on_item_activation(item);
|
||||
}
|
||||
|
||||
WSMenuItem* WSMenu::item_at(const Point& position)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue