Ticket #3870: keyfixv3.patch
File keyfixv3.patch, 3.0 KB (added by , 8 years ago) |
---|
-
source/gui/CGUI.cpp
65 65 { 66 66 InReaction ret = IN_PASS; 67 67 68 if (ev->ev.type == SDL_HOTKEYDOWN) 68 // Handle keys for input boxes 69 if ( GetFocusedObject() && 70 ((ev->ev.type == SDL_KEYDOWN && 71 ev->ev.key.keysym.sym != SDLK_ESCAPE && 72 !g_keys[SDLK_LCTRL] && !g_keys[SDLK_RCTRL] && 73 !g_keys[SDLK_LALT] && !g_keys[SDLK_RALT]) || 74 ev->ev.type == SDL_HOTKEYDOWN || 75 (ev->ev.type == SDL_KEYUP && (ev->ev.key.keysym.sym == SDLK_KP_ENTER || ev->ev.key.keysym.sym == SDLK_RETURN)) || 76 ev->ev.type == SDL_TEXTINPUT || 77 ev->ev.type == SDL_TEXTEDITING) ) 69 78 { 79 ret = GetFocusedObject()->ManuallyHandleEvent(ev); 80 } 81 82 else if (ev->ev.type == SDL_HOTKEYUP) 83 { 70 84 const char* hotkey = static_cast<const char*>(ev->ev.user.data1); 71 85 std::map<CStr, std::vector<IGUIObject*> >::iterator it = m_HotkeyObjects.find(hotkey); 72 86 if (it != m_HotkeyObjects.end()) … … 243 257 m_MousePos = oldMousePos; 244 258 } 245 259 246 // Handle keys for input boxes 247 if (GetFocusedObject()) 248 { 249 if ( 250 (ev->ev.type == SDL_KEYDOWN && 251 ev->ev.key.keysym.sym != SDLK_ESCAPE && 252 !g_keys[SDLK_LCTRL] && !g_keys[SDLK_RCTRL] && 253 !g_keys[SDLK_LALT] && !g_keys[SDLK_RALT]) 254 || ev->ev.type == SDL_HOTKEYDOWN 255 || ev->ev.type == SDL_TEXTINPUT || ev->ev.type == SDL_TEXTEDITING 256 ) 257 { 258 ret = GetFocusedObject()->ManuallyHandleEvent(ev); 259 } 260 // else will return IN_PASS because we never used the button. 261 } 262 260 // else will return IN_PASS because we never used the button. 263 261 return ret; 264 262 } 265 263 -
source/gui/CInput.cpp
95 95 { 96 96 ENSURE(m_iBufferPos != -1); 97 97 98 if (ev->ev.type == SDL_HOTKEY DOWN)98 if (ev->ev.type == SDL_HOTKEYUP) 99 99 { 100 100 if (m_ComposingText) 101 101 return IN_HANDLED; … … 181 181 182 182 return IN_HANDLED; 183 183 } 184 else if (ev->ev.type == SDL_KEYUP) 185 { 186 if (ev->ev.key.keysym.sym == SDLK_KP_ENTER || ev->ev.key.keysym.sym == SDLK_RETURN) 187 // 'Return' should do a Press event for single liners (e.g. submitting forms) 188 // otherwise a '\n' character will be added. 189 { 190 bool multiline; 191 GUI<bool>::GetSetting(this, "multiline", multiline); 192 if (!multiline) 193 { 194 SendEvent(GUIM_PRESSED, "press"); 195 UpdateBufferPositionSetting(); 196 return IN_HANDLED; 197 } 198 199 } 200 } 184 201 else if (ev->ev.type == SDL_KEYDOWN) 185 202 { 186 203 if (m_ComposingText) … … 474 491 { 475 492 bool multiline; 476 493 GUI<bool>::GetSetting(this, "multiline", multiline); 477 if ( !multiline)494 if (multiline) 478 495 { 479 SendEvent(GUIM_PRESSED, "press"); 480 break; 496 cooked = '\n'; // Change to '\n' and do default: 481 497 } 482 483 cooked = '\n'; // Change to '\n' and do default:484 498 // NOTE: Fall-through 485 499 } 486 500 default: // Insert a character