Skip to content

Commit

Permalink
Hotkeys: shouldn't be allowed to register non printable "keys"
Browse files Browse the repository at this point in the history
  • Loading branch information
bradallred committed May 13, 2018
1 parent d67ecca commit 2ee2ca5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 0 additions & 4 deletions gemrb/core/GUI/Button.cpp
Expand Up @@ -755,10 +755,6 @@ void Button::SetPushOffset(ieWord x, ieWord y)

bool Button::SetHotKey(KeyboardKey key, short mod, bool global)
{
if (key < ' ') {
return false;
}

UnregisterHotKey();

if (global) {
Expand Down
4 changes: 4 additions & 0 deletions gemrb/core/GUI/EventMgr.cpp
Expand Up @@ -155,6 +155,10 @@ void EventMgr::DispatchEvent(Event& e)

bool EventMgr::RegisterHotKeyCallback(EventCallback* cb, KeyboardKey key, short mod)
{
if (key < ' ') {
return false;
}

int flags = mod << 16;
flags |= key;

Expand Down
4 changes: 4 additions & 0 deletions gemrb/core/GUI/Window.cpp
Expand Up @@ -395,6 +395,10 @@ bool Window::InHandler() const

bool Window::RegisterHotKeyCallback(EventMgr::EventCallback* cb, KeyboardKey key)
{
if (key < ' ') {
return false;
}

std::map<KeyboardKey, EventMgr::EventCallback*>::iterator it;
it = HotKeys.find(key);
if (it != HotKeys.end()) {
Expand Down

0 comments on commit 2ee2ca5

Please sign in to comment.