Ticket #3194: cleanup_return_handled_only_if_handled.patch

File cleanup_return_handled_only_if_handled.patch, 1.0 KB (added by elexis, 7 years ago)

We should likely not return IN_HANDLED if the GUI says it didn't handle the key, needs exploration.

Line 
1Index: source/gui/CGUI.cpp
2===================================================================
3--- source/gui/CGUI.cpp (revision 19040)
4+++ source/gui/CGUI.cpp (working copy)
5@@ -73,19 +73,15 @@ InReaction CGUI::HandleEvent(const SDL_E
6
7 std::map<CStr, std::vector<IGUIObject*> >::iterator it = m_HotkeyObjects.find(hotkey);
8 if (it != m_HotkeyObjects.end())
9 for (IGUIObject* const& obj : it->second)
10 {
11 // Update hotkey status before sending the event,
12 // else the status will be outdated when processing the GUI event.
13 HotkeyInputHandler(ev);
14 ret = IN_HANDLED;
15-
16- if (ev->ev.type == SDL_HOTKEYDOWN)
17- obj->SendEvent(GUIM_PRESSED, "press");
18- else
19- obj->SendEvent(GUIM_RELEASED, "release");
20+ if ((ev->ev.type == SDL_HOTKEYDOWN && obj->SendEvent(GUIM_PRESSED, "press") == IN_HANDLED) ||
21+ (ev->ev.type == SDL_HOTKEYUP && obj->SendEvent(GUIM_RELEASED, "release") == IN_HANDLED))
22+ {
23+ ret = IN_HANDLED;
24+ }
25 }
26 }
27
28 else if (ev->ev.type == SDL_MOUSEMOTION)
29 {
30