ソースを参照

Merge pull request #1044 from Pixelized/password-text-box

Password text box
Sean Paul Taylor 12 年 前
コミット
9a67fcc633

+ 2 - 0
gameplay/CMakeLists.txt

@@ -523,6 +523,8 @@ set(GAMEPLAY_LUA
     src/lua/lua_TerrainListener.h
     src/lua/lua_TextBox.cpp
     src/lua/lua_TextBox.h
+    src/lua/lua_TextBoxInputMode.cpp
+    src/lua/lua_TextBoxInputMode.h
     src/lua/lua_Texture.cpp
     src/lua/lua_Texture.h
     src/lua/lua_TextureFilter.cpp

+ 1 - 0
gameplay/android/jni/Android.mk

@@ -253,6 +253,7 @@ LOCAL_SRC_FILES := \
     lua/lua_TerrainFlags.cpp \
     lua/lua_TerrainListener.cpp \
     lua/lua_TextBox.cpp \
+    lua/lua_TextBoxInputMode.cpp \
     lua/lua_Texture.cpp \
     lua/lua_TextureFilter.cpp \
     lua/lua_TextureFormat.cpp \

+ 2 - 0
gameplay/gameplay.vcxproj

@@ -245,6 +245,7 @@
     <ClCompile Include="src\lua\lua_TerrainFlags.cpp" />
     <ClCompile Include="src\lua\lua_TerrainListener.cpp" />
     <ClCompile Include="src\lua\lua_TextBox.cpp" />
+    <ClCompile Include="src\lua\lua_TextBoxInputMode.cpp" />
     <ClCompile Include="src\lua\lua_Texture.cpp" />
     <ClCompile Include="src\lua\lua_TextureFilter.cpp" />
     <ClCompile Include="src\lua\lua_TextureFormat.cpp" />
@@ -526,6 +527,7 @@
     <ClInclude Include="src\lua\lua_TerrainFlags.h" />
     <ClInclude Include="src\lua\lua_TerrainListener.h" />
     <ClInclude Include="src\lua\lua_TextBox.h" />
+    <ClInclude Include="src\lua\lua_TextBoxInputMode.h" />
     <ClInclude Include="src\lua\lua_Texture.h" />
     <ClInclude Include="src\lua\lua_TextureFilter.h" />
     <ClInclude Include="src\lua\lua_TextureFormat.h" />

+ 6 - 0
gameplay/gameplay.vcxproj.filters

@@ -852,6 +852,9 @@
     <ClCompile Include="src\lua\lua_RenderStateCullFaceSide.cpp">
       <Filter>src\lua</Filter>
     </ClCompile>
+    <ClCompile Include="src\lua\lua_TextBoxInputMode.cpp">
+      <Filter>src\lua</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="src\Animation.h">
@@ -1691,6 +1694,9 @@
     <ClInclude Include="src\lua\lua_RenderStateCullFaceSide.h">
       <Filter>src\lua</Filter>
     </ClInclude>
+    <ClInclude Include="src\lua\lua_TextBoxInputMode.h">
+      <Filter>src\lua</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="src\Game.inl">

+ 46 - 41
gameplay/src/TextBox.cpp

@@ -37,26 +37,7 @@ void TextBox::initialize(Theme::Style* style, Properties* properties)
     GP_ASSERT(properties);
 
     Label::initialize(style, properties);
-    const char* inputMode = properties->getString("inputMode");
-    if (inputMode)
-    {
-		if (strcasecmp(inputMode, "text") == 0)
-		{
-			_inputMode = TEXT;
-		}
-		else if (strcasecmp(inputMode, "password") == 0)
-		{
-			_inputMode = PASSWORD;
-		}
-		else
-		{
-			_inputMode = TEXT;
-		}
-    }
-	else
-	{
-		_inputMode = TEXT;
-	}
+    _inputMode = getInputMode(properties->getString("inputMode"));
 }
 
 int TextBox::getLastKeypress()
@@ -178,7 +159,7 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                 }
                 case Keyboard::KEY_LEFT_ARROW:
                 {
-					const std::string displayedText = getDisplayedText();
+                    const std::string displayedText = getDisplayedText();
                     Font* font = getFont(_state);
                     GP_ASSERT(font);
                     unsigned int fontSize = getFontSize(_state);
@@ -194,7 +175,7 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                 }
                 case Keyboard::KEY_RIGHT_ARROW:
                 {
-					const std::string displayedText = getDisplayedText();
+                    const std::string displayedText = getDisplayedText();
                     Font* font = getFont(_state);
                     GP_ASSERT(font);
                     unsigned int fontSize = getFontSize(_state);
@@ -389,7 +370,7 @@ void TextBox::setCaretLocation(int x, int y)
     unsigned int fontSize = getFontSize(_state);
     Font::Justify textAlignment = getTextAlignment(_state);
     bool rightToLeft = getTextRightToLeft(_state);
-	const std::string displayedText = getDisplayedText();
+    const std::string displayedText = getDisplayedText();
 
     int index = font->getIndexAtLocation(displayedText.c_str(), _textBounds, fontSize, _caretLocation, &_caretLocation,
             textAlignment, true, rightToLeft);
@@ -447,22 +428,22 @@ const char* TextBox::getType() const
 
 void TextBox::setPasswordChar(char character)
 {
-	_passwordChar = character;
+    _passwordChar = character;
 }
 
 char TextBox::getPasswordChar() const
 {
-	return _passwordChar;
+    return _passwordChar;
 }
 
 void TextBox::setInputMode(InputMode inputMode)
 {
-	_inputMode = inputMode;
+    _inputMode = inputMode;
 }
 
 TextBox::InputMode TextBox::getInputMode() const
 {
-	return _inputMode;
+    return _inputMode;
 }
 
 void TextBox::drawText(const Rectangle& clip)
@@ -473,28 +454,52 @@ void TextBox::drawText(const Rectangle& clip)
     // Draw the text.
     if (_font)
     {
-		const std::string displayedText = getDisplayedText();
+        const std::string displayedText = getDisplayedText();
         _font->start();
         _font->drawText(displayedText.c_str(), _textBounds, _textColor, getFontSize(_state), getTextAlignment(_state), true, getTextRightToLeft(_state), &_viewportClipBounds);
         _font->finish();
     }
 }
 
+TextBox::InputMode TextBox::getInputMode(const char* inputMode)
+{
+    if (!inputMode)
+    {
+        return TextBox::TEXT;
+    }
+
+    if (strcmp(inputMode, "TEXT") == 0)
+    {
+        return TextBox::TEXT;
+    }
+    else if (strcmp(inputMode, "PASSWORD") == 0)
+    {
+        return TextBox::PASSWORD;
+    }
+    else
+    {
+        GP_ERROR("Failed to get corresponding textbox inputmode for unsupported value '%s'.", inputMode);
+    }
+
+    // Default.
+    return TextBox::TEXT;
+}
+
 std::string TextBox::getDisplayedText() const
 {
-	std::string displayedText;
-	switch (_inputMode) {
-		case PASSWORD:
-			displayedText.insert(0, _text.length(), _passwordChar);
-			break;
-
-		case TEXT:
-		default:
-			displayedText = _text;
-			break;
-	}
-
-	return displayedText;
+    std::string displayedText;
+    switch (_inputMode) {
+        case PASSWORD:
+            displayedText.insert(0, _text.length(), _passwordChar);
+            break;
+
+        case TEXT:
+        default:
+            displayedText = _text;
+            break;
+    }
+
+    return displayedText;
 }
 
 }

+ 76 - 68
gameplay/src/TextBox.h

@@ -40,20 +40,20 @@ class TextBox : public Label
 
 public:
 
-	/**
-	 * Input modes. Default is Text.
-	 */
-	enum InputMode {
-		/**
-		 * Text: Text is displayed directly.
-		 */
-		TEXT = 0x01,
-
-		/**
-		 * Password: Text is replaced by _passwordChar, which is '*' by default.
-		 */
-		PASSWORD = 0x02
-	};
+    /**
+     * Input modes. Default is Text.
+     */
+    enum InputMode {
+        /**
+         * Text: Text is displayed directly.
+         */
+        TEXT = 0x01,
+
+        /**
+         * Password: Text is replaced by _passwordChar, which is '*' by default.
+         */
+        PASSWORD = 0x02
+    };
 
     /**
      * Create a new text box control.
@@ -69,7 +69,7 @@ public:
     /**
      * Initialize this textbox.
      */
-	virtual void initialize(Theme::Style* style, Properties* properties);
+    virtual void initialize(Theme::Style* style, Properties* properties);
 
     /**
      * Add a listener to be notified of specific events affecting
@@ -95,33 +95,33 @@ public:
      */
     const char* getType() const;
 
-	/**
-	 * Set the character displayed in password mode.
-	 *
-	 * @param character Character to display in password mode.
-	 */
-	void setPasswordChar(char character);
-
-	/**
-	 * Get the character displayed in password mode.
-	 *
-	 * @return The character displayed in password mode.
-	 */
-	char getPasswordChar() const;
-
-	/**
-	 * Set the input mode.
-	 *
-	 * @param inputMode Input mode to set.
-	 */
-	void setInputMode(InputMode inputMode);
-
-	/**
-	 * Get the input mode.
-	 *
-	 * @return The input mode.
-	 */
-	InputMode getInputMode() const;
+    /**
+     * Set the character displayed in password mode.
+     *
+     * @param character Character to display in password mode.
+     */
+    void setPasswordChar(char character);
+
+    /**
+     * Get the character displayed in password mode.
+     *
+     * @return The character displayed in password mode.
+     */
+    char getPasswordChar() const;
+
+    /**
+     * Set the input mode.
+     *
+     * @param inputMode Input mode to set.
+     */
+    void setInputMode(InputMode inputMode);
+
+    /**
+     * Get the input mode.
+     *
+     * @return The input mode.
+     */
+    InputMode getInputMode() const;
 
 protected:
 
@@ -185,24 +185,32 @@ protected:
      *
      * @param spriteBatch The sprite batch containing this control's icons.
      * @param clip The clipping rectangle of this control's parent container.
-	 */
-	void drawImages(SpriteBatch* spriteBatch, const Rectangle& clip);
-
-	/**
-	 * Draw this textbox's text.
-	 *
-	 * @param clip The clipping rectangle of this textbox's
-	 * parent container.
-	 **/
-	virtual void drawText(const Rectangle& clip);
-
-	/**
-	 * Get the text which should be displayed, depending on
-	 * _inputMode.
-	 *
-	 * @return The text to be displayed.
-	 */
-	std::string getDisplayedText() const;
+     */
+    void drawImages(SpriteBatch* spriteBatch, const Rectangle& clip);
+
+    /**
+     * Draw this textbox's text.
+     *
+     * @param clip The clipping rectangle of this textbox's
+     * parent container.
+     */
+    virtual void drawText(const Rectangle& clip);
+
+    /**
+     * Gets an InputMode by string.
+     *
+     * @param inputMode The string representation of the InputMode type.
+     * @return The InputMode enum value corresponding to the given string.
+     */
+    static InputMode getInputMode(const char* inputMode);
+
+    /**
+     * Get the text which should be displayed, depending on
+     * _inputMode.
+     *
+     * @return The text to be displayed.
+     */
+    std::string getDisplayedText() const;
 
     /**
      * The current position of the TextBox's caret.
@@ -229,15 +237,15 @@ protected:
      */
     Theme::ThemeImage* _caretImage;
 
-	/**
-	 * The character displayed in password mode.
-	 */
-	char _passwordChar;
+    /**
+     * The character displayed in password mode.
+     */
+    char _passwordChar;
 
-	/**
-	 * The mode used to display the typed text.
-	 */
-	InputMode _inputMode;
+    /**
+     * The mode used to display the typed text.
+     */
+    InputMode _inputMode;
 
 private:
 

+ 10 - 0
gameplay/src/lua/lua_Global.cpp

@@ -794,6 +794,14 @@ void luaRegister_lua_Global()
         gameplay::ScriptUtil::registerConstantString("LEVEL_OF_DETAIL", "LEVEL_OF_DETAIL", scopePath);
     }
 
+    // Register enumeration TextBox::InputMode.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("TextBox");
+        gameplay::ScriptUtil::registerConstantString("TEXT", "TEXT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PASSWORD", "PASSWORD", scopePath);
+    }
+
     // Register enumeration Texture::Filter.
     {
         std::vector<std::string> scopePath;
@@ -937,6 +945,8 @@ const char* lua_stringFromEnumGlobal(std::string& enumname, unsigned int value)
         return lua_stringFromEnum_SceneDebugFlags((Scene::DebugFlags)value);
     if (enumname == "Terrain::Flags")
         return lua_stringFromEnum_TerrainFlags((Terrain::Flags)value);
+    if (enumname == "TextBox::InputMode")
+        return lua_stringFromEnum_TextBoxInputMode((TextBox::InputMode)value);
     if (enumname == "Texture::Filter")
         return lua_stringFromEnum_TextureFilter((Texture::Filter)value);
     if (enumname == "Texture::Format")

+ 1 - 0
gameplay/src/lua/lua_Global.h

@@ -40,6 +40,7 @@
 #include "lua_RenderStateDepthFunction.h"
 #include "lua_SceneDebugFlags.h"
 #include "lua_TerrainFlags.h"
+#include "lua_TextBoxInputMode.h"
 #include "lua_TextureFilter.h"
 #include "lua_TextureFormat.h"
 #include "lua_TextureWrap.h"

+ 200 - 0
gameplay/src/lua/lua_TextBox.cpp

@@ -17,6 +17,7 @@
 #include "lua_ControlState.h"
 #include "lua_CurveInterpolationType.h"
 #include "lua_FontJustify.h"
+#include "lua_TextBoxInputMode.h"
 
 namespace gameplay
 {
@@ -55,10 +56,12 @@ void luaRegister_TextBox()
         {"getImageColor", lua_TextBox_getImageColor},
         {"getImageRegion", lua_TextBox_getImageRegion},
         {"getImageUVs", lua_TextBox_getImageUVs},
+        {"getInputMode", lua_TextBox_getInputMode},
         {"getLastKeypress", lua_TextBox_getLastKeypress},
         {"getMargin", lua_TextBox_getMargin},
         {"getOpacity", lua_TextBox_getOpacity},
         {"getPadding", lua_TextBox_getPadding},
+        {"getPasswordChar", lua_TextBox_getPasswordChar},
         {"getRefCount", lua_TextBox_getRefCount},
         {"getSkinColor", lua_TextBox_getSkinColor},
         {"getSkinRegion", lua_TextBox_getSkinRegion},
@@ -73,6 +76,7 @@ void luaRegister_TextBox()
         {"getX", lua_TextBox_getX},
         {"getY", lua_TextBox_getY},
         {"getZIndex", lua_TextBox_getZIndex},
+        {"initialize", lua_TextBox_initialize},
         {"isContainer", lua_TextBox_isContainer},
         {"isEnabled", lua_TextBox_isEnabled},
         {"isVisible", lua_TextBox_isVisible},
@@ -95,9 +99,11 @@ void luaRegister_TextBox()
         {"setHeight", lua_TextBox_setHeight},
         {"setImageColor", lua_TextBox_setImageColor},
         {"setImageRegion", lua_TextBox_setImageRegion},
+        {"setInputMode", lua_TextBox_setInputMode},
         {"setMargin", lua_TextBox_setMargin},
         {"setOpacity", lua_TextBox_setOpacity},
         {"setPadding", lua_TextBox_setPadding},
+        {"setPasswordChar", lua_TextBox_setPasswordChar},
         {"setPosition", lua_TextBox_setPosition},
         {"setSize", lua_TextBox_setSize},
         {"setSkinColor", lua_TextBox_setSkinColor},
@@ -1766,6 +1772,41 @@ int lua_TextBox_getImageUVs(lua_State* state)
     return 0;
 }
 
+int lua_TextBox_getInputMode(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                TextBox* instance = getInstance(state);
+                TextBox::InputMode result = instance->getInputMode();
+
+                // Push the return value onto the stack.
+                lua_pushstring(state, lua_stringFromEnum_TextBoxInputMode(result));
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_TextBox_getInputMode - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_TextBox_getLastKeypress(lua_State* state)
 {
     // Get the number of parameters.
@@ -1945,6 +1986,41 @@ int lua_TextBox_getPadding(lua_State* state)
     return 0;
 }
 
+int lua_TextBox_getPasswordChar(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                TextBox* instance = getInstance(state);
+                char result = instance->getPasswordChar();
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_TextBox_getPasswordChar - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_TextBox_getRefCount(lua_State* state)
 {
     // Get the number of parameters.
@@ -2603,6 +2679,58 @@ int lua_TextBox_getZIndex(lua_State* state)
     return 0;
 }
 
+int lua_TextBox_initialize(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
+                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<Theme::Style> param1 = gameplay::ScriptUtil::getObjectPointer<Theme::Style>(2, "ThemeStyle", false, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Theme::Style'.");
+                    lua_error(state);
+                }
+
+                // Get parameter 2 off the stack.
+                bool param2Valid;
+                gameplay::ScriptUtil::LuaArray<Properties> param2 = gameplay::ScriptUtil::getObjectPointer<Properties>(3, "Properties", false, &param2Valid);
+                if (!param2Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Properties'.");
+                    lua_error(state);
+                }
+
+                TextBox* instance = getInstance(state);
+                instance->initialize(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_TextBox_initialize - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_TextBox_isContainer(lua_State* state)
 {
     // Get the number of parameters.
@@ -3652,6 +3780,42 @@ int lua_TextBox_setImageRegion(lua_State* state)
     return 0;
 }
 
+int lua_TextBox_setInputMode(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                TextBox::InputMode param1 = (TextBox::InputMode)lua_enumFromString_TextBoxInputMode(luaL_checkstring(state, 2));
+
+                TextBox* instance = getInstance(state);
+                instance->setInputMode(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_TextBox_setInputMode - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_TextBox_setMargin(lua_State* state)
 {
     // Get the number of parameters.
@@ -3806,6 +3970,42 @@ int lua_TextBox_setPadding(lua_State* state)
     return 0;
 }
 
+int lua_TextBox_setPasswordChar(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                char param1 = (char)luaL_checkint(state, 2);
+
+                TextBox* instance = getInstance(state);
+                instance->setPasswordChar(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_TextBox_setPasswordChar - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_TextBox_setPosition(lua_State* state)
 {
     // Get the number of parameters.

+ 5 - 0
gameplay/src/lua/lua_TextBox.h

@@ -36,10 +36,12 @@ int lua_TextBox_getId(lua_State* state);
 int lua_TextBox_getImageColor(lua_State* state);
 int lua_TextBox_getImageRegion(lua_State* state);
 int lua_TextBox_getImageUVs(lua_State* state);
+int lua_TextBox_getInputMode(lua_State* state);
 int lua_TextBox_getLastKeypress(lua_State* state);
 int lua_TextBox_getMargin(lua_State* state);
 int lua_TextBox_getOpacity(lua_State* state);
 int lua_TextBox_getPadding(lua_State* state);
+int lua_TextBox_getPasswordChar(lua_State* state);
 int lua_TextBox_getRefCount(lua_State* state);
 int lua_TextBox_getSkinColor(lua_State* state);
 int lua_TextBox_getSkinRegion(lua_State* state);
@@ -54,6 +56,7 @@ int lua_TextBox_getWidth(lua_State* state);
 int lua_TextBox_getX(lua_State* state);
 int lua_TextBox_getY(lua_State* state);
 int lua_TextBox_getZIndex(lua_State* state);
+int lua_TextBox_initialize(lua_State* state);
 int lua_TextBox_isContainer(lua_State* state);
 int lua_TextBox_isEnabled(lua_State* state);
 int lua_TextBox_isVisible(lua_State* state);
@@ -76,9 +79,11 @@ int lua_TextBox_setFontSize(lua_State* state);
 int lua_TextBox_setHeight(lua_State* state);
 int lua_TextBox_setImageColor(lua_State* state);
 int lua_TextBox_setImageRegion(lua_State* state);
+int lua_TextBox_setInputMode(lua_State* state);
 int lua_TextBox_setMargin(lua_State* state);
 int lua_TextBox_setOpacity(lua_State* state);
 int lua_TextBox_setPadding(lua_State* state);
+int lua_TextBox_setPasswordChar(lua_State* state);
 int lua_TextBox_setPosition(lua_State* state);
 int lua_TextBox_setSize(lua_State* state);
 int lua_TextBox_setSkinColor(lua_State* state);

+ 31 - 0
gameplay/src/lua/lua_TextBoxInputMode.cpp

@@ -0,0 +1,31 @@
+#include "Base.h"
+#include "lua_TextBoxInputMode.h"
+
+namespace gameplay
+{
+
+static const char* enumStringEmpty = "";
+
+static const char* luaEnumString_TextBoxInputMode_TEXT = "TEXT";
+static const char* luaEnumString_TextBoxInputMode_PASSWORD = "PASSWORD";
+
+TextBox::InputMode lua_enumFromString_TextBoxInputMode(const char* s)
+{
+    if (strcmp(s, luaEnumString_TextBoxInputMode_TEXT) == 0)
+        return TextBox::TEXT;
+    if (strcmp(s, luaEnumString_TextBoxInputMode_PASSWORD) == 0)
+        return TextBox::PASSWORD;
+    return TextBox::TEXT;
+}
+
+const char* lua_stringFromEnum_TextBoxInputMode(TextBox::InputMode e)
+{
+    if (e == TextBox::TEXT)
+        return luaEnumString_TextBoxInputMode_TEXT;
+    if (e == TextBox::PASSWORD)
+        return luaEnumString_TextBoxInputMode_PASSWORD;
+    return enumStringEmpty;
+}
+
+}
+

+ 15 - 0
gameplay/src/lua/lua_TextBoxInputMode.h

@@ -0,0 +1,15 @@
+#ifndef LUA_TEXTBOXINPUTMODE_H_
+#define LUA_TEXTBOXINPUTMODE_H_
+
+#include "TextBox.h"
+
+namespace gameplay
+{
+
+// Lua bindings for enum conversion functions for TextBox::InputMode.
+TextBox::InputMode lua_enumFromString_TextBoxInputMode(const char* s);
+const char* lua_stringFromEnum_TextBoxInputMode(TextBox::InputMode e);
+
+}
+
+#endif

+ 1 - 1
samples/browser/res/common/forms/formBasicControls.form

@@ -67,7 +67,7 @@ form basicControls
         style = topLeftAlignedEntry
         position = 20, 540
         size = 250, 40
-        text = password
+        text = PASSWORD
         consumeInputEvents = true
         inputMode = PASSWORD
     }