Преглед на файлове

Fixed #1537. Android Onscreen Keyboard now return uppercase and lowercase

seanpaultaylor преди 11 години
родител
ревизия
12f6989be8
променени са 2 файла, в които са добавени 21 реда и са изтрити 1 реда
  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:
 
     /**