summaryrefslogtreecommitdiff
path: root/src/signs_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-06-15 15:31:22 +0000
committerfrosch <frosch@openttd.org>2013-06-15 15:31:22 +0000
commitfef30983e643943df24a7090a7175cfa66f3ba15 (patch)
tree5129b4c530168788d3a4ebec180d3c910c37b942 /src/signs_gui.cpp
parentee4e68bd5e4882397bc023040a2977047d22ccb7 (diff)
downloadopenttd-fef30983e643943df24a7090a7175cfa66f3ba15.tar.xz
(svn r25414) -Codechange: Move handling of global hotkeys to HotkeyList.
Diffstat (limited to 'src/signs_gui.cpp')
-rw-r--r--src/signs_gui.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 3966742f0..665603cf0 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -338,11 +338,24 @@ struct SignListWindow : Window, SignList {
static HotkeyList hotkeys;
};
+/**
+ * Handler for global hotkeys of the SignListWindow.
+ * @param hotkey Hotkey
+ * @return ES_HANDLED if hotkey was accepted.
+ */
+static EventState SignListGlobalHotkeys(int hotkey)
+{
+ if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
+ Window *w = ShowSignList();
+ if (w == NULL) return ES_NOT_HANDLED;
+ return w->OnHotkey(hotkey);
+}
+
static Hotkey signlist_hotkeys[] = {
Hotkey('F', "focus_filter_box", SLHK_FOCUS_FILTER_BOX),
HOTKEY_LIST_END
};
-HotkeyList SignListWindow::hotkeys("signlist", signlist_hotkeys);
+HotkeyList SignListWindow::hotkeys("signlist", signlist_hotkeys, SignListGlobalHotkeys);
static const NWidgetPart _nested_sign_list_widgets[] = {
NWidget(NWID_HORIZONTAL),
@@ -391,15 +404,6 @@ Window *ShowSignList()
return AllocateWindowDescFront<SignListWindow>(&_sign_list_desc, 0);
}
-EventState SignListGlobalHotkeys(uint16 key, uint16 keycode)
-{
- int num = SignListWindow::hotkeys.CheckMatch(keycode, true);
- if (num == -1) return ES_NOT_HANDLED;
- Window *w = ShowSignList();
- if (w == NULL) return ES_NOT_HANDLED;
- return w->OnHotkey(num);
-}
-
/**
* Actually rename the sign.
* @param index the sign to rename.