Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/ObjectTypes/CInput.cpp
Show First 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | case SDL_TEXTEDITING: | ||||
UpdateAutoScroll(); | UpdateAutoScroll(); | ||||
SendEvent(GUIM_TEXTEDIT, EventNameTextEdit); | SendEvent(GUIM_TEXTEDIT, EventNameTextEdit); | ||||
return IN_HANDLED; | return IN_HANDLED; | ||||
} | } | ||||
case SDL_KEYDOWN: | case SDL_KEYDOWN: | ||||
{ | { | ||||
if (m_ComposingText) | |||||
return IN_HANDLED; | |||||
// Since the GUI framework doesn't handle to set settings | // Since the GUI framework doesn't handle to set settings | ||||
// in Unicode (CStrW), we'll simply retrieve the actual | // in Unicode (CStrW), we'll simply retrieve the actual | ||||
// pointer and edit that. | // pointer and edit that. | ||||
SDL_Keycode keyCode = ev->ev.key.keysym.sym; | SDL_Keycode keyCode = ev->ev.key.keysym.sym; | ||||
// Escape is treated specially to let players close out windows even if an input is in focus. | // Regular text input is handled in SDL_TEXTINPUT, however keydown events are still sent (and they come first). | ||||
// TODO: there is maybe a better way to only handle text-like keys here? | // To make things work correctly, we pass through 'escape' which is a non-character key. | ||||
if (keyCode == SDLK_ESCAPE) | // TODO: there are probably other keys that we could ignore, but recognizing "non-glyph" keys isn't that trivial. | ||||
// Further, don't input text if modifiers other than shift are pressed (the user is presumably trying to perform a hotkey). | |||||
if (keyCode == SDLK_ESCAPE || | |||||
g_keys[SDLK_LCTRL] || g_keys[SDLK_RCTRL] || | |||||
g_keys[SDLK_LALT] || g_keys[SDLK_RALT] || | |||||
g_keys[SDLK_LGUI] || g_keys[SDLK_RGUI]) | |||||
return IN_PASS; | return IN_PASS; | ||||
if (m_ComposingText) | |||||
return IN_HANDLED; | |||||
ManuallyImmutableHandleKeyDownEvent(keyCode); | ManuallyImmutableHandleKeyDownEvent(keyCode); | ||||
ManuallyMutableHandleKeyDownEvent(keyCode); | ManuallyMutableHandleKeyDownEvent(keyCode); | ||||
UpdateBufferPositionSetting(); | UpdateBufferPositionSetting(); | ||||
return IN_HANDLED; | return IN_HANDLED; | ||||
} | } | ||||
default: | default: | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | if (!m_MultiLine) | ||||
break; | break; | ||||
} | } | ||||
cooked = '\n'; // Change to '\n' and do default: | cooked = '\n'; // Change to '\n' and do default: | ||||
FALLTHROUGH; | FALLTHROUGH; | ||||
} | } | ||||
default: // Insert a character | default: // Insert a character | ||||
{ | { | ||||
// In SDL2, we no longer get Unicode wchars via SDL_Keysym | // Regular input is handled via SDL_TEXTINPUT, so we should ignore it here. | ||||
// we use text input events instead and they provide UTF-8 chars | |||||
if (cooked == 0) | if (cooked == 0) | ||||
return; | return; | ||||
// Check max length | // Check max length | ||||
if (m_MaxLength != 0 && m_Caption.length() >= static_cast<size_t>(m_MaxLength)) | if (m_MaxLength != 0 && m_Caption.length() >= static_cast<size_t>(m_MaxLength)) | ||||
break; | break; | ||||
m_WantedX = 0.0f; | m_WantedX = 0.0f; | ||||
▲ Show 20 Lines • Show All 1,731 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator