guiTextEditCtrl_ScriptBinding.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. ConsoleMethodGroupBeginWithDocs(GuiTextEditCtrl, GuiControl)
  23. /*! Get the contents of the textedit control.
  24. @return The current text in the textedit box.
  25. */
  26. ConsoleMethodWithDocs(GuiTextEditCtrl, getText, ConsoleString, 2, 2, "()")
  27. {
  28. if (!object->hasText())
  29. return StringTable->EmptyString;
  30. char *retBuffer = Con::getReturnBuffer(GuiTextEditCtrl::MAX_STRING_LENGTH);
  31. object->getText(retBuffer);
  32. return retBuffer;
  33. }
  34. /*! Gets the current position of the text cursor in the control.
  35. @return The current position of the text cursor in the control, where 0 is at the beginning of the line, 1 is after the first letter, and so on.
  36. */
  37. ConsoleMethodWithDocs(GuiTextEditCtrl, getCursorPos, ConsoleInt, 2, 2, "()")
  38. {
  39. return(object->getCursorPos());
  40. }
  41. /*! Sets the current position of the text cursor in the control.
  42. @param newPos The new position to place the cursor at, where 0 is at the beginning of the line, 1 is after the first letter, and so on.
  43. @return No return value.
  44. */
  45. ConsoleMethodWithDocs(GuiTextEditCtrl, setCursorPos, ConsoleVoid, 3, 3, "( newPos )")
  46. {
  47. object->reallySetCursorPos(dAtoi(argv[2]));
  48. }
  49. /*! Selects all the text in the control.
  50. @return No return value.
  51. */
  52. ConsoleMethodWithDocs(GuiTextEditCtrl, selectAllText, ConsoleVoid, 2, 2, "()")
  53. {
  54. object->selectAllText();
  55. }
  56. /*! Calls the validation function for the control. This is depreciated. Please use validate() instead.
  57. @return No return value.
  58. */
  59. ConsoleMethodWithDocs(GuiTextEditCtrl, forceValidateText, ConsoleBool, 2, 2, "()")
  60. {
  61. Con::warnf("GuiTextEditCtrl::forceValidateText() is depreciated. Please use GuiTextEditCtrl::validate() instead.");
  62. return object->validate();
  63. }
  64. /*! Calls the validation function for the control.
  65. @return No return value.
  66. */
  67. ConsoleMethodWithDocs(GuiTextEditCtrl, validate, ConsoleBool, 2, 2, "()")
  68. {
  69. return object->validate();
  70. }
  71. /*! Sets the returnCausesTab flag. If true, the pressing enter will attempt to tab to the next control. False will keep the focus in this control.
  72. @param setting True to turn on the flag. False otherwise.
  73. @return No return value
  74. */
  75. ConsoleMethodWithDocs(GuiTextEditCtrl, setReturnCausesTab, ConsoleVoid, 3, 3, (setting))
  76. {
  77. object->setReturnCausesTab(dAtob(argv[2]));
  78. }
  79. /*! Returns if the returnCausesTab flag is on.
  80. @return Returns the state of the returnCausesTab flag.
  81. */
  82. ConsoleMethodWithDocs(GuiTextEditCtrl, getReturnCausesTab, ConsoleBool, 2, 2, ())
  83. {
  84. return object->getReturnCausesTab();
  85. }
  86. /*! Sets the sinkAllKeyEvents flag. If true, the tab key will act like the enter key.
  87. @param setting True to turn on the flag. False otherwise.
  88. @return No return value
  89. */
  90. ConsoleMethodWithDocs(GuiTextEditCtrl, setSinkAllKeyEvents, ConsoleVoid, 3, 3, (setting))
  91. {
  92. object->setSinkAllKeyEvents(dAtob(argv[2]));
  93. }
  94. /*! Returns if the sinkAllKeyEvents flag is on.
  95. @return Returns the state of the sinkAllKeyEvents flag.
  96. */
  97. ConsoleMethodWithDocs(GuiTextEditCtrl, getSinkAllKeyEvents, ConsoleBool, 2, 2, ())
  98. {
  99. return object->getSinkAllKeyEvents();
  100. }
  101. /*! Sets the password flag. If true, the tab key will act like the enter key.
  102. @param setting True to turn on the flag. False otherwise.
  103. @return No return value
  104. */
  105. ConsoleMethodWithDocs(GuiTextEditCtrl, setIsPassword, ConsoleVoid, 3, 3, (setting))
  106. {
  107. object->setIsPassword(dAtob(argv[2]));
  108. }
  109. /*! Returns if the password flag is on.
  110. @return Returns the state of the password flag.
  111. */
  112. ConsoleMethodWithDocs(GuiTextEditCtrl, getIsPassword, ConsoleBool, 2, 2, ())
  113. {
  114. return object->getIsPassword();
  115. }
  116. /*! Sets the maxLength which is the max number of characters that can be entered in the text edit box.
  117. @param max An integer value between 1 and 1024.
  118. @return No return value
  119. */
  120. ConsoleMethodWithDocs(GuiTextEditCtrl, setMaxLength, ConsoleVoid, 3, 3, (max))
  121. {
  122. object->setMaxLength(dAtoi(argv[2]));
  123. }
  124. /*! Returns if the current maxLength.
  125. @return Returns the maxLength.
  126. */
  127. ConsoleMethodWithDocs(GuiTextEditCtrl, getMaxLength, ConsoleBool, 2, 2, ())
  128. {
  129. return object->getMaxLength();
  130. }
  131. /*! Sets the InputMode. Possible values include AllText, Decimal, Number, Alpha, and AlphaNumeric.
  132. @param mode The InputMode to use.
  133. @return No return value.
  134. */
  135. ConsoleMethodWithDocs(GuiTextEditCtrl, setInputMode, ConsoleVoid, 3, 3, (mode))
  136. {
  137. // Fetch body type.
  138. const GuiTextEditCtrl::InputMode mode = GuiTextEditCtrl::getInputModeEnum(argv[2]);
  139. // Set body type.
  140. object->setInputMode(mode);
  141. }
  142. /*! Gets the text edit InputMode.
  143. @return The InputMode.
  144. */
  145. ConsoleMethodWithDocs(GuiTextEditCtrl, getInputMode, ConsoleString, 2, 2, ())
  146. {
  147. return GuiTextEditCtrl::getInputModeDescription(object->getInputMode());
  148. }
  149. ConsoleMethodGroupEndWithDocs(GuiTextEditCtrl)