Przeglądaj źródła

Merge pull request #1554 from seanpaultaylor/next

Next
Sean Taylor 11 lat temu
rodzic
commit
26c1dcff8d
2 zmienionych plików z 21 dodań i 1 usunięć
  1. 16 1
      gameplay/src/TextBox.cpp
  2. 5 0
      gameplay/src/TextBox.h

+ 16 - 1
gameplay/src/TextBox.cpp

@@ -4,7 +4,7 @@
 namespace gameplay
 {
 
-TextBox::TextBox() : _caretLocation(0), _lastKeypress(0), _fontSize(0), _caretImage(NULL), _passwordChar('*'), _inputMode(TEXT), _ctrlPressed(false)
+TextBox::TextBox() : _caretLocation(0), _lastKeypress(0), _fontSize(0), _caretImage(NULL), _passwordChar('*'), _inputMode(TEXT), _ctrlPressed(false), _shiftPressed(false)
 {
     _canFocus = true;
 }
@@ -140,6 +140,11 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
         {
             switch (key)
             {
+            	case Keyboard::KEY_SHIFT:
+            	{
+                    _shiftPressed = true;
+                    break;
+            	}
                 case Keyboard::KEY_CTRL:
                 {
                     _ctrlPressed = true;
@@ -257,6 +262,11 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                     return false;
                 default:
                 {
+                    // Insert character into string, only if our font supports this character
+                    if (_shiftPressed && islower(key))
+                    {
+                        key = toupper(key);
+                    }
                     // Insert character into string, only if our font supports this character
                     if (_font && _font->isCharacterSupported(key))
                     {
@@ -278,6 +288,11 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
         case Keyboard::KEY_RELEASE:
             switch (key)
             {
+            	case Keyboard::KEY_SHIFT:
+            	{
+                    _shiftPressed = false;
+                    break;
+             	 }
                 case Keyboard::KEY_CTRL:
                 {
                     _ctrlPressed = false;

+ 5 - 0
gameplay/src/TextBox.h

@@ -237,6 +237,11 @@ protected:
      */
     bool _ctrlPressed;
 
+    /**
+     * Indicate if the SHIFT key is currently pressed.
+     */
+    bool _shiftPressed = false;
+
 private:
 
     /**