/lib/titanium/mobile/ui/Picker.hx

http://github.com/visup/haxe-titanium-api · Haxe · 167 lines · 38 code · 6 blank · 123 comment · 0 complexity · 3826db5985633f2a7630c2ce087aa409 MD5 · raw file

  1. package titanium.mobile.ui;
  2. import titanium.mobile.core.BaseView;
  3. import titanium.mobile.core.Dispatcher;
  4. import titanium.mobile.core.Point;
  5. /**
  6. Picker class
  7. Documentation available at:
  8. http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Picker-object.html
  9. - namespace
  10. Titanium.UI.Picker
  11. - type
  12. object
  13. - subtype
  14. proxy
  15. - description
  16. A Picker is created by the method [Titanium.UI.createPicker](Titanium.UI.createPicker). A Picker can be used to select one or more fixed values.
  17. - since
  18. 0.8
  19. - platforms
  20. android, iphone, ipad
  21. - properties
  22. columns[array]: array of column values
  23. type[int]: the type constant for the picker. One of `Titanium.UI.PICKER_TYPE_PLAIN` (default), `Titanium.UI.PICKER_TYPE_DATE_AND_TIME`, `Titanium.UI.PICKER_TYPE_DATE`, `Titanium.UI.PICKER_TYPE_TIME` or `Titanium.UI.PICKER_TYPE_COUNT_DOWN_TIMER`.
  24. selectionIndicator[boolean]: for basic picker, boolean value to indicate whether the visual selection style is shown. On the iPhone, this is a blue selected bar.
  25. minDate[date]: the minimum Date/Time for value for date pickers
  26. maxDate[date]:the maximum Date/Time for value for date pickers
  27. value[date]: the Date/Time value for date pickers
  28. countDownDuration[double]: the duration value in milliseconds for count down timer pickers
  29. locale[string]: the locale used for displaying Date/Time pickers values
  30. minuteInterval[int]: property to set the interval displayed by the minutes wheel (for example, 15 minutes). The interval value must be evenly divided into 60; if it is not, the default value is used. The default and minimum values are 1; the maximum value is 30.
  31. - methods
  32. add: add an array of rows, a single row or a column to the picker
  33. reloadColumn: causes the picker to reload the values from the new column
  34. getSelectedRow: get the selected row object for column
  35. setSelectedRow: set the column's row to the selected state
  36. - method : getSelectedRow, object
  37. index[int]: for the column index, return the row object or nil if not found
  38. - method : setSelectedRow
  39. column[int]: the column index
  40. row[int]: the row index
  41. animated[boolean]: boolean to indicate if the selection should be animated (default)
  42. - method : add
  43. data[array,object]: add an array of rows, a single row or a column to the picker
  44. - method : reloadColumn
  45. column[object]: new column to load
  46. - events
  47. change: fired when the value of a picker row and/or column changes
  48. - event : change
  49. selectedValue: (plain picker only) the array of selected values, one element per column in the picker.
  50. value: (date/time pickers only) the selected date/time value.
  51. rowIndex: the selected row index
  52. columnIndex: the selected column index
  53. column: the column object
  54. row: the row object
  55. - example : Basic Single Column Picker
  56. In this basic picker example, we create a one column picker with 4 rows.
  57. ~~~
  58. var picker = Titanium.UI.createPicker();
  59. var data = [];
  60. data[0]=Titanium.UI.createPickerRow({title:'Bananas'});
  61. data[1]=Titanium.UI.createPickerRow({title:'Strawberries'});
  62. data[2]=Titanium.UI.createPickerRow({title:'Mangos'});
  63. data[3]=Titanium.UI.createPickerRow({title:'Grapes'});
  64. picker.add(data);
  65. ~~~
  66. - example : Custom View for Row
  67. In this example, we use a custom label for each row in a column.
  68. ~~~
  69. var picker = Titanium.UI.createPicker();
  70. var row = Titanium.UI.createPickerRow();
  71. var label = Titanium.UI.createLabel({
  72. text:text,
  73. font:{fontSize:24,fontWeight:'bold'},
  74. color:text,
  75. width:'auto',
  76. height:'auto'
  77. });
  78. row.add(label);
  79. picker.add(row);
  80. ~~~
  81. - notes
  82. Android does not support the DateTime or Count Down Timer picker type.
  83. **/
  84. typedef PickerChangeEvent =
  85. { > Event,
  86. column:Dynamic,
  87. columnIndex:Int,
  88. row:Dynamic,
  89. rowIndex:Int,
  90. selectedValue:Array<Dynamic>,
  91. value:Date
  92. }
  93. @:native("Titanium.UI.Picker")
  94. extern class Picker extends BaseView
  95. {
  96. // static constructor
  97. public inline static function create(?params:Dynamic):Picker
  98. return titanium.mobile.UI.createPicker(params)
  99. // events
  100. public static inline var CHANGE_EVENT = "change";
  101. // properties
  102. public var columns:Array<Dynamic>;
  103. public var countDownDuration:Float;
  104. public var locale:String;
  105. public var minDate:Date;
  106. public var maxDate:Date;
  107. public var minuteInterval:Int;
  108. public var selectionIndicator:Bool;
  109. public var type:Int;
  110. public var value:Date;
  111. #if androidos
  112. public var format24:Bool;
  113. public var useSpinner:Bool;
  114. public var visibleItems:Int;
  115. #end
  116. // methods
  117. override function add(data:Dynamic):Void;
  118. public function setSelectedRow(col:Int, row:Int, animated:Bool):Void;
  119. public function getSelectedRow(colIndex:Int):Dynamic;
  120. public function reloadColumn(column:Dynamic):Void;
  121. }