소스 검색

Corrects input issues when typing into text fields and it bleeding through to player inputs.

Areloch 10 년 전
부모
커밋
4c13906865

+ 9 - 6
Engine/source/windowManager/sdl/sdlWindow.cpp

@@ -484,12 +484,6 @@ void PlatformWindowSDL::_triggerKeyNotify(const SDL_Event& evt)
       keyEvent.trigger(getWindowId(), torqueModifiers, inputAction, torqueKey);
       keyEvent.trigger(getWindowId(), torqueModifiers, inputAction, torqueKey);
       //Con::printf("Key %d : %d", tKey.sym, inputAction);
       //Con::printf("Key %d : %d", tKey.sym, inputAction);
    }
    }
-
-   // stop SDL_TEXTINPUT event when unwanted
-   if( inputAction == IA_MAKE && getKeyboardTranslation() && shouldNotTranslate( torqueModifiers, torqueKey ) )	
-      SDL_StopTextInput();
-   else   
-      SDL_StartTextInput();
 }
 }
 
 
 void PlatformWindowSDL::_triggerTextNotify(const SDL_Event& evt)
 void PlatformWindowSDL::_triggerTextNotify(const SDL_Event& evt)
@@ -606,3 +600,12 @@ const UTF16 *PlatformWindowSDL::getCurtainWindowClassName()
    static String str("CurtainWindowClassName");
    static String str("CurtainWindowClassName");
    return str.utf16();
    return str.utf16();
 }
 }
+
+void PlatformWindowSDL::setKeyboardTranslation(const bool enabled)
+{
+   mEnableKeyboardTranslation = enabled;
+   if (mEnableKeyboardTranslation)
+      SDL_StartTextInput();
+   else
+      SDL_StopTextInput();
+}

+ 3 - 0
Engine/source/windowManager/sdl/sdlWindow.h

@@ -160,6 +160,9 @@ public:
    virtual bool isMouseLocked() const { return mMouseLocked; };
    virtual bool isMouseLocked() const { return mMouseLocked; };
    virtual bool shouldLockMouse() const { return mShouldLockMouse; };
    virtual bool shouldLockMouse() const { return mShouldLockMouse; };
 
 
+   /// Set if relevant keypress events should be translated into character input events.
+   virtual void setKeyboardTranslation(const bool enabled);
+
    virtual WindowId getWindowId();
    virtual WindowId getWindowId();
 
 
    SDL_Window* getSDLWindow() const { return mWindowHandle; }
    SDL_Window* getSDLWindow() const { return mWindowHandle; }

+ 5 - 0
Engine/source/windowManager/windowInputGenerator.cpp

@@ -105,6 +105,11 @@ void WindowInputGenerator::generateInputEvent( InputEventInfo &inputEvent )
    if( mInputController->processInputEvent( inputEvent ) )
    if( mInputController->processInputEvent( inputEvent ) )
       return;
       return;
 
 
+   if (mWindow->getKeyboardTranslation())
+   {
+      return;
+   }
+
    // If we get here we failed to process it with anything prior... so let
    // If we get here we failed to process it with anything prior... so let
    // the ActionMap handle it.
    // the ActionMap handle it.
    ActionMap::handleEvent(&inputEvent);
    ActionMap::handleEvent(&inputEvent);