/lib/titanium/mobile/ui/TextArea.hx

http://github.com/visup/haxe-titanium-api · Haxe · 185 lines · 50 code · 10 blank · 125 comment · 0 complexity · aecb35439b62058bb0edce9cc7621232 MD5 · raw file

  1. package titanium.mobile.ui;
  2. import titanium.mobile.core.BaseView;
  3. import titanium.mobile.core.Dispatcher;
  4. /**
  5. TextArea class
  6. Documentation available at:
  7. http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.TextArea-object.html
  8. - namespace
  9. Titanium.UI.TextArea
  10. - type
  11. object
  12. - subtype
  13. view
  14. - description
  15. A Text Area is created by the method `Titanium.UI.createTextArea`. The Text Area is a multiline field.
  16. - since
  17. 0.8
  18. - platforms
  19. android, iphone, ipad
  20. - properties
  21. enabled[boolean]: boolean indicating the enabled state of the field
  22. editable[boolean]: boolean indicating if the field is editable
  23. backgroundColor[string]: value of the background color of the field
  24. value[string]: value of the field
  25. keyboardToolbar[array]: array of toolbar button objects to be used when the keyboard is displayed
  26. keyboardToolbarColor[string]: the color of the keyboard toolbar
  27. keyboardToolbarHeight[float]: the height of the keyboard toolbar
  28. suppressReturn[boolean]: boolean to indicate if the return key should be suppressed during entry
  29. autocapitalization[int]: One of `Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE`, `Titanium.UI.TEXT_AUTOCAPITALIZATION_WORDS`, `Titanium.UI.TEXT_AUTOCAPITALIZATION_SENTENCES`, or `Titanium.UI.TEXT_AUTOCAPITALIZATION_ALL` to indicate how the field should be capitalized during typing. (only Android)
  30. autoLink[int]: whether or not to convert text within this area to clickable links. iOS only.
  31. - methods
  32. focus: force the field to gain focus
  33. blur: force the field to lose focus
  34. hasText: return boolean (true) if the field has text
  35. - events
  36. focus: fired when the field gains focus
  37. blur: fired when the field loses focus
  38. return: fired when the field return key is pressed on the keyboard
  39. change: fired when the field value changes
  40. selected: fired when the text in the field is selected
  41. - event : selected
  42. range: the range of text. range is an object with the properties `location` and `length`.
  43. - event : change
  44. value: the value of the field upon change
  45. - event : blur
  46. value: the value of the field upon blur
  47. - event : focus
  48. value: the value of the field upon focus
  49. - event : return
  50. value: the value of the field upon return
  51. - example : Basic Text Area with Customizations
  52. This example created a highly customized text area.
  53. ~~~
  54. var ta1 = Titanium.UI.createTextArea({
  55. value:'I am a textarea',
  56. height:70,
  57. width:300,
  58. top:60,
  59. font:{fontSize:20,fontFamily:'Marker Felt', fontWeight:'bold'},
  60. color:'#888',
  61. textAlign:'left',
  62. appearance:Titanium.UI.KEYBOARD_APPEARANCE_ALERT,
  63. keyboardType:Titanium.UI.KEYBOARD_NUMBERS_PUNCTUATION,
  64. returnKeyType:Titanium.UI.RETURNKEY_EMERGENCY_CALL,
  65. borderWidth:2,
  66. borderColor:'#bbb',
  67. borderRadius:5
  68. });
  69. ~~~
  70. - notes
  71. Both Text Areas and Text Fields can control the buttons displayed in a button bar above the keyboard when it's visible.
  72. Example using a custom keyboard toolbar:
  73. ~~~
  74. var textfield = Titanium.UI.createTextField({
  75. color:'#336699',
  76. value:'Focus to see keyboard w/ toolbar',
  77. height:35,
  78. width:300,
  79. top:10,
  80. borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
  81. keyboardToolbar:[flexSpace,camera, flexSpace,tf,flexSpace, send,flexSpace],
  82. keyboardToolbarColor: '#999',
  83. keyboardToolbarHeight: 40,
  84. });
  85. ~~~
  86. **/
  87. typedef TextAreaBlurEvent =
  88. { > Event,
  89. value:String
  90. }
  91. typedef TextAreaChangeEvent =
  92. { > Event,
  93. value:String
  94. }
  95. typedef TextAreaFocusEvent =
  96. { > Event,
  97. value:String
  98. }
  99. typedef TextAreaReturnEvent =
  100. { > Event,
  101. value:String
  102. }
  103. typedef TextAreaSelectedEvent =
  104. { > Event,
  105. range:Dynamic
  106. }
  107. @:native("Titanium.UI.TextArea")
  108. extern class TextArea extends BaseView
  109. {
  110. // static constructor
  111. public inline static function create(?params:Dynamic):TextArea
  112. return titanium.mobile.UI.createTextArea(params)
  113. // events
  114. public static inline var BLUR_EVENT = "blur";
  115. public static inline var CHANGE_EVENT = "change";
  116. public static inline var FOCUS_EVENT = "focus";
  117. public static inline var RETURN_EVENT = "return";
  118. public static inline var SELECTED_EVENT = "selected";
  119. // properties
  120. #if androidos
  121. public var autocapitalization:Int;
  122. #end
  123. #if iphoneos
  124. public var autoLink:Int;
  125. #end
  126. public var editable:Bool;
  127. public var enabled:Bool;
  128. public var keyboardToolbar:Array<Dynamic>;
  129. public var keyboardToolbarColor:String;
  130. public var keyboardToolbarHeight:Float;
  131. public var suppressReturn:Bool;
  132. public var value:String;
  133. // methods
  134. public function blur():Void;
  135. public function focus():Void;
  136. public function hasText():Bool;
  137. }