mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibGUI: Change GUI::KeyEvent::key() type to KeyCode
...instead of a plain int. Yay for some type safety.
This commit is contained in:
parent
abfcd7b1b8
commit
fce49b3e32
5 changed files with 11 additions and 5 deletions
|
@ -264,14 +264,14 @@ enum MouseButton : u8 {
|
|||
|
||||
class KeyEvent final : public Event {
|
||||
public:
|
||||
KeyEvent(Type type, int key, u8 modifiers)
|
||||
KeyEvent(Type type, KeyCode key, u8 modifiers)
|
||||
: Event(type)
|
||||
, m_key(key)
|
||||
, m_modifiers(modifiers)
|
||||
{
|
||||
}
|
||||
|
||||
int key() const { return m_key; }
|
||||
KeyCode key() const { return m_key; }
|
||||
bool ctrl() const { return m_modifiers & Mod_Ctrl; }
|
||||
bool alt() const { return m_modifiers & Mod_Alt; }
|
||||
bool shift() const { return m_modifiers & Mod_Shift; }
|
||||
|
@ -283,7 +283,7 @@ public:
|
|||
|
||||
private:
|
||||
friend class WindowServerConnection;
|
||||
int m_key { 0 };
|
||||
KeyCode m_key { 0 };
|
||||
u8 m_modifiers { 0 };
|
||||
String m_text;
|
||||
};
|
||||
|
|
|
@ -129,7 +129,7 @@ void WindowServerConnection::handle(const Messages::WindowClient::KeyDown& messa
|
|||
if (!window)
|
||||
return;
|
||||
|
||||
auto key_event = make<KeyEvent>(Event::KeyDown, message.key(), message.modifiers());
|
||||
auto key_event = make<KeyEvent>(Event::KeyDown, (KeyCode) message.key(), message.modifiers());
|
||||
if (message.character() != '\0') {
|
||||
char ch = message.character();
|
||||
key_event->m_text = String(&ch, 1);
|
||||
|
@ -188,7 +188,7 @@ void WindowServerConnection::handle(const Messages::WindowClient::KeyUp& message
|
|||
if (!window)
|
||||
return;
|
||||
|
||||
auto key_event = make<KeyEvent>(Event::KeyUp, message.key(), message.modifiers());
|
||||
auto key_event = make<KeyEvent>(Event::KeyUp, (KeyCode) message.key(), message.modifiers());
|
||||
if (message.character() != '\0') {
|
||||
char ch = message.character();
|
||||
key_event->m_text = String(&ch, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue