mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:47:35 +00:00
LibGUI: Add a to_string helper for GUI::MouseButton
It's useful to be able to print mouse button names to the user in other parts of the system. Went with a hardcoded switch instead of an enumeration macro like KeyCode since there were only a handful of cases, and it's unlikely that many more will ever be added (but can always change it then)
This commit is contained in:
parent
5b56f3ed5b
commit
8b9b836a0e
1 changed files with 20 additions and 0 deletions
|
@ -546,4 +546,24 @@ private:
|
|||
NonnullRefPtr<Action> m_action;
|
||||
};
|
||||
|
||||
inline StringView mouse_button_to_string(MouseButton key)
|
||||
{
|
||||
switch (key) {
|
||||
case MouseButton::None:
|
||||
return "None";
|
||||
case MouseButton::Primary:
|
||||
return "Primary";
|
||||
case MouseButton::Secondary:
|
||||
return "Secondary";
|
||||
case MouseButton::Middle:
|
||||
return "Middle";
|
||||
case MouseButton::Backward:
|
||||
return "Backward";
|
||||
case MouseButton::Forward:
|
||||
return "Forward";
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue