/
Picker.yml
578 lines (477 loc) Β· 21.1 KB
/
Picker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
---
name: Titanium.UI.Picker
summary: |
A control used to select one or more fixed values.
description: |
Use the <Titanium.UI.createPicker> method or Alloy **`<Picker>`** element to create a picker control.
On Android, the `useSpinner` property must be enabled to support multiple columns.
By default, the spinner is automatically sized to fit its content and can overflow
to additional spinner rows. The size of the picker can be adjusted with the `width`
and `height` properties, but may omit picker columns or cut off picker rows
if the size is set too small.
On iOS, by default, the size of the picker, including its background, is fixed at the
same size as the iPhone keyboard to respect the
[iOS Human Interface Guidelines](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/Controls.html#//apple_ref/doc/uid/TP40006556-CH15-SW3).
The size of the picker should not be modified.
The contents of the picker are sized to fit the picker, which may cut off text
in the picker rows. Adding views to picker rows is also supported on iOS.
On iPad, Apple recommends using a picker only in a popover. Since the size of the picker
cannot be adjusted, it is not suitable for the main screen.
On Mobile Web and Tizen, by default, the picker fills the entire view it is contained in
but is adjustable using the `width` and `height` properties.
extends: Titanium.UI.View
excludes: {
properties: [
anchorPoint,backgroundDisabledColor,backgroundDisabledImage,backgroundFocusedColor,
backgroundFocusedImage,backgroundGradient,backgroundImage,backgroundLeftCap,backgroundRepeat,
backgroundSelectedColor,backgroundSelectedImage,backgroundTopCap,center,enabled,layout,tintColor,zIndex
],
methods: [ remove, removeAllChildren ]
}
since: "0.8"
platforms: [android, iphone, ipad, mobileweb, tizen]
methods:
- name: add
summary: Adds rows or columns to the picker.
description: |
Once you use this method to add rows and columns to a picker, you cannot remove or
manipulate them.
parameters:
- name: data
summary: |
A row, set of rows, a column of rows or a set of columns of rows. When this method is
used to add a row or set of rows, a single-column picker is created.
type: [Array<Titanium.UI.PickerRow>, Titanium.UI.PickerRow, Array<Titanium.UI.PickerColumn>, Titanium.UI.PickerColumn]
- name: getSelectedRow
summary: Gets the selected row for a column, or `null` if none exists.
parameters:
- name: index
summary: A column index.
type: Number
returns:
- type: Titanium.UI.PickerRow
- name: reloadColumn
summary: Repopulates values for a column.
parameters:
- name: column
summary: Column to repopulate.
type: Titanium.UI.PickerColumn
platforms: [iphone, ipad]
- name: setSelectedRow
summary: Selects a column's row.
description: On iOS, this method must be called after the picker is rendered.
parameters:
- name: column
summary: A column index.
type: Number
- name: row
summary: A row index.
type: Number
- name: animated
summary: |
Determines whether the selection should be animated. (iPhone, iPad-only)
type: Boolean
default: true
optional: true
- name: setValue
summary: Sets the date and time value property for Date pickers.
description: |
Applicable to the <Titanium.UI.PICKER_TYPE_DATE> and <Titanium.UI.PICKER_TYPE_DATE_AND_TIME>
picker types.
platforms: [iphone, ipad]
parameters:
- name: date
summary: A Javascript `Date` object.
type: Object
- name: suppressEvent
summary: Determines whether a `change` event is fired.
type: Boolean
default: true
returns:
- type: Titanium.UI.PickerRow
- name: showDatePickerDialog
summary: Shows Date picker as a modal dialog.
description: |
Applicable to the <Titanium.UI.PICKER_TYPE_DATE> picker type.
See "Date Picker using showDatePickerDialog()" for an example.
parameters:
- name: dictObj
summary: |
Dictionary object with a subset of `Titanium.UI.Picker` properties
and a callback defined. Acceptable object properties are
`callback`, `okButtonTitle`, `title` and `value`.
type: Object
platforms: [android]
- name: showTimePickerDialog
summary: Shows Time picker as a modal dialog.
description: |
Applicable to the <Titanium.UI.PICKER_TYPE_TIME> picker type.
See "Date Picker using showDatePickerDialog()" for a similar example.
parameters:
- name: dictObj
summary: |
Dictionary object with a subset of `Titanium.UI.Picker` properties
and a callback defined. Acceptable object properties are
`callback`, `format24`, `okButtonTitle`, `title` and `value`.
type: Object
platforms: [android]
events:
- name: change
summary: Fired when the value of any column's row is changed.
properties:
- name: columnIndex
summary: |
Selected column index. On iOS, Tizen and Mobile Web, only applicable to <Titanium.UI.PICKER_TYPE_PLAIN>
picker types.
type: Number
- name: rowIndex
summary: |
Selected row index. On iOS, Tizen and Mobile Web, only applicable to <Titanium.UI.PICKER_TYPE_PLAIN>
picker types.
type: Number
- name: column
summary: |
The column object. On iOS, Tizen and Mobile Web, only applicable to <Titanium.UI.PICKER_TYPE_PLAIN>
picker types.
type: Titanium.UI.PickerColumn
- name: countDownDuration
summary: |
The selected duration in milliseconds. Applicable to <Titanium.UI.PICKER_TYPE_COUNT_DOWN_TIMER> picker types.
type: Number
- name: value
summary: |
The selected value. Applicable to date/time pickers only. This property is read-only
on Android.
type: String
- name: row
summary: |
The row object. On iOS, Tizen and Mobile Web, only applicable to <Titanium.UI.PICKER_TYPE_PLAIN> picker types.
type: Titanium.UI.PickerRow
- name: selectedValue
summary: |
Array of selected values, one element per column in the picker. Applicable to
<Titanium.UI.PICKER_TYPE_PLAIN> picker types.
type: Array<String>
- name: click
summary: Fired when the device detects a click against the view.
platforms: [android]
since: "3.0.0"
description: |
This event is only available for non-spinner plain pickers.
properties:
- name: x
type: Number
summary: X coordinate of the event from the `source` view's coordinate system.
- name: y
summary: Y coordinate of the event from the `source` view's coordinate system.
type: Number
properties:
- name: backgroundColor
platforms: [android]
- name: columns
summary: Columns used for this picker, as an array of <Titanium.UI.PickerColumn> objects.
description: |
In an Alloy application you can specify this property with a `<PickerColumn>` (or `<Column>`)
element that contains one or more `<PickerRow>` (or `<Row>`) elements, as shown below:
<Alloy>
<Window>
<Picker useSpinner="true">
<PickerColumn id="column1">
<PickerRow title="Bananas"/>
<PickerRow title="Strawberries"/>
<PickerRow title="Mangos"/>
</PickerColumn>
<!-- Picker shorthand notation -->
<Column id="column2">
<Row title="red"/>
<Row title="green"/>
<Row title="blue"/>
</Column>
</Picker>
</Window>
</Alloy>
type: Array<Titanium.UI.PickerColumn>
- name: countDownDuration
summary: Duration in milliseconds used for a Countdown Timer picker.
description: |
Applicable to <Titanium.UI.PICKER_TYPE_COUNT_DOWN_TIMER> picker types.
type: Number
platforms: [iphone, ipad]
- name: format24
summary: |
Determines whether the Time pickers display in 24-hour or 12-hour clock format.
description: |
Applicable to <Titanium.UI.PICKER_TYPE_TIME> and <Titanium.UI.PICKER_TYPE_DATE_AND_TIME>
picker types.
When this property is enabled, a time picker is displayed with hours 0 through 23,
or with hours 1 through 12 and am/pm controls otherwise.
For backward compatibility, the default value of this property depends on the style of
picker in use.
For a spinner picker (when `useSpinner` is `true`), this defaults to `true` (24-hour format.)
For a native picker (when `useSpinner` is either un-set or `false`), this defaults to `false`
(12-hour format.)
The value of this property may be modified even after a picker is rendered and the UI will be
updated accordingly.
type: Boolean
default: true (spinner enabled), false (otherwise)
platforms: [android]
- name: locale
summary: Locale used when displaying Date and Time picker values.
description: |
Applicable to <Titanium.UI.PICKER_TYPE_DATE>, <Titanium.UI.PICKER_TYPE_TIME> and
<Titanium.UI.PICKER_TYPE_DATE_AND_TIME> picker types.
Locale must be represented as a combination of ISO 2-letter language and country codes.
For example, `en-US` or `en-GB`. See the
[ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) and
[ISO 3166-1 alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
sections of wikipedia for reference.
On iOS, the system locale is always used.
type: String
default: System Settings
platforms: [android]
- name: maxDate
summary: Maximum date displayed when a Date picker is in use.
description: |
Applicable to <Titanium.UI.PICKER_TYPE_DATE> and <Titanium.UI.PICKER_TYPE_DATE_AND_TIME>
picker types.
For JavaScript files, use a JavaScript Date object.
For Alloy XML and TSS files, use a date string that can be parsed by the
[moment.js constructor](http://momentjs.com/docs/#/parsing/string/),
which includes ISO-8601 and RFC2822 dates.
This property is ignored when `maxDate` is less than `minDate`.
type: Date
- name: minDate
summary: Minimum date displayed when a Date picker is in use.
description: |
Applicable to <Titanium.UI.PICKER_TYPE_DATE> and <Titanium.UI.PICKER_TYPE_DATE_AND_TIME>
picker types.
For JavaScript files, use a JavaScript Date object.
For Alloy XML and TSS files, use a date string that can be parsed by the
[moment.js constructor](http://momentjs.com/docs/#/parsing/string/),
which includes ISO-8601 and RFC2822 dates.
This property is ignored when `maxDate` is less than `minDate`.
type: Date
- name: minuteInterval
summary: |
Interval in minutes displayed when one of the Time types of pickers is in use.
description: |
Applicable to <Titanium.UI.PICKER_TYPE_TIME> and <Titanium.UI.PICKER_TYPE_DATE_AND_TIME>
picker types.
The minimum permitted value is 1 and maximum is 30. If the value cannot be evenly divided
into 60, the default value is used.
type: Number
default: 1
platforms: [iphone, ipad]
- name: selectionIndicator
summary: |
Determines whether the visual selection indicator is shown.
description: |
If `true`, selection indicator is enabled.
On iOS 7 and later, the picker indicator is always shown and you cannot control it.
On iOS 6 and prior, if enabled, a blue bar is displayed to indicate the current selection.
type: Boolean
default: true (Android), false (iPhone, iPad)
platforms: [android, iphone, ipad]
- name: type
summary: Determines the type of picker displayed
description: |
`PICKER_TYPE_DATE_AND_TIME` is only available for iOS and Mobile Web, Tizen.
`PICKER_TYPE_COUNT_DOWN_TIMER` is only available for iOS.
Mobile Web and Tizen rely on input types for date and time types, but as of Q1 2012 these input types
are not supported on most browsers, those that do support it support it poorly, and no fall-back
exists. It is recommended not to use these types on Mobile Web and Tizen until browser support improves.
type: Number
constants: Titanium.UI.PICKER_TYPE_*
default: <Titanium.UI.PICKER_TYPE_PLAIN>
- name: useSpinner
summary: |
Determines whether the non-native Android control, with a spinning wheel that looks and
behaves like the iOS picker, is invoked rather than the default native "dropdown" style.
description: |
If `true`, the spinner is enabled.
This property should be set either at picker creation, i.e.
`Titanium.UI.createPicker({ useSpinner:true });`, or before the picker is added to its parent.
This property must be enabled for multi-column pickers.
type: Boolean
default: false
platforms: [android]
- name: value
summary: Date and time value for Date pickers.
description: |
Applicable to <Titanium.UI.PICKER_TYPE_DATE> and <Titanium.UI.PICKER_TYPE_DATE_AND_TIME>
picker types.
For JavaScript files, use a JavaScript Date object.
For Alloy XML and TSS files, use a date string that can be parsed by the
[moment.js constructor](http://momentjs.com/docs/#/parsing/string/),
which includes ISO-8601 and RFC2822 dates.
type: Date
- name: visibleItems
summary: |
Number of visible rows to display. This is only applicable to a plain picker and when the
`useSpinner` is `true`.
description: |
The spinner-style Android picker shows 5 rows by default; one selected in the middle and 2
above and below. Set to an odd number to ensure the selected row is in the middle.
type: Number
default: 5
platforms: [android]
- name: calendarViewShown
summary: |
Determines whether the calenderView is visible.
description: |
If 'calendarViewShown' is 'true', the calenderView is visible
type: Boolean
default: false
platforms: [android]
- name: font
summary: Font to use for text.
type: Font
examples:
- title: Multi-Column Picker using Alloy XML Markup
example: |
Creates a picker with two columns. You can optionally use `Column` and `Row` as shorthand
notation for `PickerColumn` and `PickerRow`, respectively.
`app/views/index.xml`:
<Alloy>
<Window id="win" backgroundColor="white" layout="vertical" exitOnClose="true">
<Picker id="picker" top="50" selectionIndicator="true" useSpinner="true">
<PickerColumn id="column1">
<PickerRow title="Bananas"/>
<PickerRow title="Strawberries"/>
<PickerRow title="Mangos"/>
<PickerRow title="Grapes"/>
</PickerColumn>
<!-- Picker shorthand notation -->
<Column id="column2">
<Row title="red"/>
<Row title="green"/>
<Row title="blue"/>
<Row title="orange"/>
</Column>
</Picker>
</Window>
</Alloy>
- title: Date Picker using Alloy XML Markup
example: |
Creates a date picker, then monitors the `change` event to see when the user updates the picker.
For the date string, use string values accepted by the moment.js constructor in the XML and TSS files.
If you are defining dates in the controller code, use a JavaScript Date object.
`app/views/index.xml`:
<Alloy>
<Window backgroundColor="blue">
<Picker id="picker"
onChange="report"
type="Ti.UI.PICKER_TYPE_DATE"
minDate="2014,4,1"
maxDate="May 1, 2014 12:00:00"
value="2014-04-15T12:00:00">
</Picker>
</Window>
</Alloy>
`app/controllers/index.js`:
function report(e) {
Ti.API.info('User selected: ' + e.value);
}
$.index.open();
- title: Basic Single Column Picker
example: |
Create a one-column, platform-specific style, picker and automatically select a row.
Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow({
exitOnClose: true,
layout: 'vertical'
});
var picker = Ti.UI.createPicker({
top:50
});
var data = [];
data[0]=Ti.UI.createPickerRow({title:'Bananas'});
data[1]=Ti.UI.createPickerRow({title:'Strawberries'});
data[2]=Ti.UI.createPickerRow({title:'Mangos'});
data[3]=Ti.UI.createPickerRow({title:'Grapes'});
picker.add(data);
picker.selectionIndicator = true;
win.add(picker);
win.open();
// must be after picker has been displayed
picker.setSelectedRow(0, 2, false); // select Mangos
- title: Multi-Column Picker
example: |
Create a two-column, platform-specific style, picker and automatically select a row in
each column.
Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow({
exitOnClose: true,
layout: 'vertical'
});
var picker = Ti.UI.createPicker({
top:50,
useSpinner: true
});
picker.selectionIndicator = true;
var fruit = [ 'Bananas', 'Strawberries', 'Mangos', 'Grapes' ];
var color = [ 'red', 'green', 'blue', 'orange' ];
var column1 = Ti.UI.createPickerColumn();
for(var i=0, ilen=fruit.length; i<ilen; i++){
var row = Ti.UI.createPickerRow({
title: fruit[i]
});
column1.addRow(row);
}
var column2 = Ti.UI.createPickerColumn();
for(var i=0, ilen=color.length; i<ilen; i++){
var row = Ti.UI.createPickerRow({ title: color[i] });
column2.addRow(row);
}
picker.add([column1,column2]);
win.add(picker);
win.open();
// must be after picker has been displayed
picker.setSelectedRow(0, 2, false); // select Mangos
picker.setSelectedRow(1, 3, false); // select Orange
- title: Date Picker
example: |
Create a date picker and handle the subsequent user action.
Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow({
exitOnClose: true,
layout: 'vertical'
});
var picker = Ti.UI.createPicker({
type:Ti.UI.PICKER_TYPE_DATE,
minDate:new Date(2009,0,1),
maxDate:new Date(2014,11,31),
value:new Date(2014,3,12),
top:50
});
win.add(picker);
win.open();
picker.addEventListener('change',function(e){
Ti.API.info("User selected date: " + e.value.toLocaleString());
});
- title: Date Picker using showDatePickerDialog() (Android only)
example: |
Create a date picker that is automatically displayed as a modal dialog and handle the
subsequent user action.
Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow({
exitOnClose: true,
layout: 'vertical'
});
var picker = Ti.UI.createPicker({
type:Ti.UI.PICKER_TYPE_DATE,
minDate:new Date(2009,0,1),
maxDate:new Date(2014,11,31),
value:new Date(2014,3,12)
});
win.open();
picker.showDatePickerDialog({
value: new Date(2010,8,1),
callback: function(e) {
if (e.cancel) {
Ti.API.info('User canceled dialog');
} else {
Ti.API.info('User selected date: ' + e.value);
}
}
});