-
Notifications
You must be signed in to change notification settings - Fork 385
/
PickerList.as
1846 lines (1717 loc) · 49.2 KB
/
PickerList.as
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
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Feathers
Copyright 2012-2015 Bowler Hat LLC. All Rights Reserved.
This program is free software. You can redistribute and/or modify it in
accordance with the terms of the accompanying license agreement.
*/
package feathers.controls
{
import feathers.controls.popups.CalloutPopUpContentManager;
import feathers.controls.popups.IPopUpContentManager;
import feathers.controls.popups.VerticalCenteredPopUpContentManager;
import feathers.core.FeathersControl;
import feathers.core.IFocusDisplayObject;
import feathers.core.IToggle;
import feathers.core.PropertyProxy;
import feathers.data.ListCollection;
import feathers.events.CollectionEventType;
import feathers.events.FeathersEventType;
import feathers.skins.IStyleProvider;
import feathers.system.DeviceCapabilities;
import flash.ui.Keyboard;
import starling.core.Starling;
import starling.events.Event;
import starling.events.EventDispatcher;
import starling.events.KeyboardEvent;
import starling.events.Touch;
import starling.events.TouchEvent;
import starling.events.TouchPhase;
/**
* Dispatched when the pop-up list is opened.
*
* <p>The properties of the event object have the following values:</p>
* <table class="innertable">
* <tr><th>Property</th><th>Value</th></tr>
* <tr><td><code>bubbles</code></td><td>false</td></tr>
* <tr><td><code>currentTarget</code></td><td>The Object that defines the
* event listener that handles the event. For example, if you use
* <code>myButton.addEventListener()</code> to register an event listener,
* myButton is the value of the <code>currentTarget</code>.</td></tr>
* <tr><td><code>data</code></td><td>null</td></tr>
* <tr><td><code>target</code></td><td>The Object that dispatched the event;
* it is not always the Object listening for the event. Use the
* <code>currentTarget</code> property to always access the Object
* listening for the event.</td></tr>
* </table>
*
* @eventType starling.events.Event.OPEN
*/
[Event(name="open",type="starling.events.Event")]
/**
* Dispatched when the pop-up list is closed.
*
* <p>The properties of the event object have the following values:</p>
* <table class="innertable">
* <tr><th>Property</th><th>Value</th></tr>
* <tr><td><code>bubbles</code></td><td>false</td></tr>
* <tr><td><code>currentTarget</code></td><td>The Object that defines the
* event listener that handles the event. For example, if you use
* <code>myButton.addEventListener()</code> to register an event listener,
* myButton is the value of the <code>currentTarget</code>.</td></tr>
* <tr><td><code>data</code></td><td>null</td></tr>
* <tr><td><code>target</code></td><td>The Object that dispatched the event;
* it is not always the Object listening for the event. Use the
* <code>currentTarget</code> property to always access the Object
* listening for the event.</td></tr>
* </table>
*
* @eventType starling.events.Event.CLOSE
*/
[Event(name="close",type="starling.events.Event")]
/**
* Dispatched when the selected item changes.
*
* <p>The properties of the event object have the following values:</p>
* <table class="innertable">
* <tr><th>Property</th><th>Value</th></tr>
* <tr><td><code>bubbles</code></td><td>false</td></tr>
* <tr><td><code>currentTarget</code></td><td>The Object that defines the
* event listener that handles the event. For example, if you use
* <code>myButton.addEventListener()</code> to register an event listener,
* myButton is the value of the <code>currentTarget</code>.</td></tr>
* <tr><td><code>data</code></td><td>null</td></tr>
* <tr><td><code>target</code></td><td>The Object that dispatched the event;
* it is not always the Object listening for the event. Use the
* <code>currentTarget</code> property to always access the Object
* listening for the event.</td></tr>
* </table>
*
* @eventType starling.events.Event.CHANGE
*/
[Event(name="change",type="starling.events.Event")]
/**
* Displays a button that may be triggered to display a pop-up list.
* The list may be customized to display in different ways, such as a
* drop-down, in a <code>Callout</code>, or as a modal overlay.
*
* <p>The following example creates a picker list, gives it a data provider,
* tells the item renderer how to interpret the data, and listens for when
* the selection changes:</p>
*
* <listing version="3.0">
* var list:PickerList = new PickerList();
*
* list.dataProvider = new ListCollection(
* [
* { text: "Milk", thumbnail: textureAtlas.getTexture( "milk" ) },
* { text: "Eggs", thumbnail: textureAtlas.getTexture( "eggs" ) },
* { text: "Bread", thumbnail: textureAtlas.getTexture( "bread" ) },
* { text: "Chicken", thumbnail: textureAtlas.getTexture( "chicken" ) },
* ]);
*
* list.listProperties.itemRendererFactory = function():IListItemRenderer
* {
* var renderer:DefaultListItemRenderer = new DefaultListItemRenderer();
* renderer.labelField = "text";
* renderer.iconSourceField = "thumbnail";
* return renderer;
* };
*
* list.addEventListener( Event.CHANGE, list_changeHandler );
*
* this.addChild( list );</listing>
*
* @see ../../../help/picker-list.html How to use the Feathers PickerList component
*/
public class PickerList extends FeathersControl implements IFocusDisplayObject
{
/**
* @private
*/
protected static const INVALIDATION_FLAG_BUTTON_FACTORY:String = "buttonFactory";
/**
* @private
*/
protected static const INVALIDATION_FLAG_LIST_FACTORY:String = "listFactory";
/**
* The default value added to the <code>styleNameList</code> of the button.
*
* @see feathers.core.FeathersControl#styleNameList
*/
public static const DEFAULT_CHILD_STYLE_NAME_BUTTON:String = "feathers-picker-list-button";
/**
* DEPRECATED: Replaced by <code>PickerList.DEFAULT_CHILD_STYLE_NAME_BUTTON</code>.
*
* <p><strong>DEPRECATION WARNING:</strong> This property is deprecated
* starting with Feathers 2.1. It will be removed in a future version of
* Feathers according to the standard
* <a target="_top" href="../../../help/deprecation-policy.html">Feathers deprecation policy</a>.</p>
*
* @see PickerList#DEFAULT_CHILD_STYLE_NAME_BUTTON
*/
public static const DEFAULT_CHILD_NAME_BUTTON:String = DEFAULT_CHILD_STYLE_NAME_BUTTON;
/**
* The default value added to the <code>styleNameList</code> of the pop-up
* list.
*
* @see feathers.core.FeathersControl#styleNameList
*/
public static const DEFAULT_CHILD_STYLE_NAME_LIST:String = "feathers-picker-list-list";
/**
* DEPRECATED: Replaced by <code>PickerList.DEFAULT_CHILD_STYLE_NAME_LIST</code>.
*
* <p><strong>DEPRECATION WARNING:</strong> This property is deprecated
* starting with Feathers 2.1. It will be removed in a future version of
* Feathers according to the standard
* <a target="_top" href="../../../help/deprecation-policy.html">Feathers deprecation policy</a>.</p>
*
* @see PickerList#DEFAULT_CHILD_STYLE_NAME_LIST
*/
public static const DEFAULT_CHILD_NAME_LIST:String = DEFAULT_CHILD_STYLE_NAME_LIST;
/**
* The default <code>IStyleProvider</code> for all <code>PickerList</code>
* components.
*
* @default null
* @see feathers.core.FeathersControl#styleProvider
*/
public static var globalStyleProvider:IStyleProvider;
/**
* @private
*/
protected static function defaultButtonFactory():Button
{
return new Button();
}
/**
* @private
*/
protected static function defaultListFactory():List
{
return new List();
}
/**
* Constructor.
*/
public function PickerList()
{
super();
}
/**
* The default value added to the <code>styleNameList</code> of the
* button. This variable is <code>protected</code> so that sub-classes
* can customize the button style name in their constructors instead of
* using the default style name defined by
* <code>DEFAULT_CHILD_STYLE_NAME_BUTTON</code>.
*
* <p>To customize the button style name without subclassing, see
* <code>customButtonStyleName</code>.</p>
*
* @see #customButtonStyleName
* @see feathers.core.FeathersControl#styleNameList
*/
protected var buttonStyleName:String = DEFAULT_CHILD_STYLE_NAME_BUTTON;
/**
* DEPRECATED: Replaced by <code>buttonStyleName</code>.
*
* <p><strong>DEPRECATION WARNING:</strong> This property is deprecated
* starting with Feathers 2.1. It will be removed in a future version of
* Feathers according to the standard
* <a target="_top" href="../../../help/deprecation-policy.html">Feathers deprecation policy</a>.</p>
*
* @see #buttonStyleName
*/
protected function get buttonName():String
{
return this.buttonStyleName;
}
/**
* @private
*/
protected function set buttonName(value:String):void
{
this.buttonStyleName = value;
}
/**
* The default value added to the <code>styleNameList</code> of the
* pop-up list. This variable is <code>protected</code> so that
* sub-classes can customize the list style name in their constructors
* instead of using the default style name defined by
* <code>DEFAULT_CHILD_STYLE_NAME_LIST</code>.
*
* <p>To customize the pop-up list name without subclassing, see
* <code>customListStyleName</code>.</p>
*
* @see #customListStyleName
* @see feathers.core.FeathersControl#styleNameList
*/
protected var listStyleName:String = DEFAULT_CHILD_STYLE_NAME_LIST;
/**
* DEPRECATED: Replaced by <code>listStyleName</code>.
*
* <p><strong>DEPRECATION WARNING:</strong> This property is deprecated
* starting with Feathers 2.1. It will be removed in a future version of
* Feathers according to the standard
* <a target="_top" href="../../../help/deprecation-policy.html">Feathers deprecation policy</a>.</p>
*
* @see #listStyleName
*/
protected function get listName():String
{
return this.listStyleName;
}
/**
* @private
*/
protected function set listName(value:String):void
{
this.listStyleName = value;
}
/**
* The button sub-component.
*
* <p>For internal use in subclasses.</p>
*
* @see #buttonFactory
* @see #createButton()
*/
protected var button:Button;
/**
* The list sub-component.
*
* <p>For internal use in subclasses.</p>
*
* @see #listFactory
* @see #createList()
*/
protected var list:List;
/**
* @private
*/
override protected function get defaultStyleProvider():IStyleProvider
{
return PickerList.globalStyleProvider;
}
/**
* @private
*/
protected var _dataProvider:ListCollection;
/**
* The collection of data displayed by the list.
*
* <p>The following example passes in a data provider and tells the item
* renderer how to interpret the data:</p>
*
* <listing version="3.0">
* list.dataProvider = new ListCollection(
* [
* { text: "Milk", thumbnail: textureAtlas.getTexture( "milk" ) },
* { text: "Eggs", thumbnail: textureAtlas.getTexture( "eggs" ) },
* { text: "Bread", thumbnail: textureAtlas.getTexture( "bread" ) },
* { text: "Chicken", thumbnail: textureAtlas.getTexture( "chicken" ) },
* ]);
*
* list.listProperties.itemRendererFactory = function():IListItemRenderer
* {
* var renderer:DefaultListItemRenderer = new DefaultListItemRenderer();
* renderer.labelField = "text";
* renderer.iconSourceField = "thumbnail";
* return renderer;
* };</listing>
*
* @default null
*/
public function get dataProvider():ListCollection
{
return this._dataProvider;
}
/**
* @private
*/
public function set dataProvider(value:ListCollection):void
{
if(this._dataProvider == value)
{
return;
}
var oldSelectedIndex:int = this.selectedIndex;
var oldSelectedItem:Object = this.selectedItem;
if(this._dataProvider)
{
this._dataProvider.removeEventListener(CollectionEventType.RESET, dataProvider_multipleEventHandler);
this._dataProvider.removeEventListener(CollectionEventType.ADD_ITEM, dataProvider_multipleEventHandler);
this._dataProvider.removeEventListener(CollectionEventType.REMOVE_ITEM, dataProvider_multipleEventHandler);
this._dataProvider.removeEventListener(CollectionEventType.REPLACE_ITEM, dataProvider_multipleEventHandler);
}
this._dataProvider = value;
if(this._dataProvider)
{
this._dataProvider.addEventListener(CollectionEventType.RESET, dataProvider_multipleEventHandler);
this._dataProvider.addEventListener(CollectionEventType.ADD_ITEM, dataProvider_multipleEventHandler);
this._dataProvider.addEventListener(CollectionEventType.REMOVE_ITEM, dataProvider_multipleEventHandler);
this._dataProvider.addEventListener(CollectionEventType.REPLACE_ITEM, dataProvider_multipleEventHandler);
}
if(!this._dataProvider || this._dataProvider.length == 0)
{
this.selectedIndex = -1;
}
else
{
this.selectedIndex = 0;
}
//this ensures that Event.CHANGE will dispatch for selectedItem
//changing, even if selectedIndex has not changed.
if(this.selectedIndex == oldSelectedIndex && this.selectedItem != oldSelectedItem)
{
this.dispatchEventWith(Event.CHANGE);
}
this.invalidate(INVALIDATION_FLAG_DATA);
}
/**
* @private
*/
protected var _ignoreSelectionChanges:Boolean = false;
/**
* @private
*/
protected var _selectedIndex:int = -1;
/**
* The index of the currently selected item. Returns <code>-1</code> if
* no item is selected.
*
* <p>The following example selects an item by its index:</p>
*
* <listing version="3.0">
* list.selectedIndex = 2;</listing>
*
* <p>The following example clears the selected index:</p>
*
* <listing version="3.0">
* list.selectedIndex = -1;</listing>
*
* <p>The following example listens for when selection changes and
* requests the selected index:</p>
*
* <listing version="3.0">
* function list_changeHandler( event:Event ):void
* {
* var list:PickerList = PickerList( event.currentTarget );
* var index:int = list.selectedIndex;
*
* }
* list.addEventListener( Event.CHANGE, list_changeHandler );</listing>
*
* @default -1
*
* @see #selectedItem
*/
public function get selectedIndex():int
{
return this._selectedIndex;
}
/**
* @private
*/
public function set selectedIndex(value:int):void
{
if(this._selectedIndex == value)
{
return;
}
this._selectedIndex = value;
this.invalidate(INVALIDATION_FLAG_SELECTED);
this.dispatchEventWith(Event.CHANGE);
}
/**
* The currently selected item. Returns <code>null</code> if no item is
* selected.
*
* <p>The following example changes the selected item:</p>
*
* <listing version="3.0">
* list.selectedItem = list.dataProvider.getItemAt(0);</listing>
*
* <p>The following example clears the selected item:</p>
*
* <listing version="3.0">
* list.selectedItem = null;</listing>
*
* <p>The following example listens for when selection changes and
* requests the selected item:</p>
*
* <listing version="3.0">
* function list_changeHandler( event:Event ):void
* {
* var list:PickerList = PickerList( event.currentTarget );
* var item:Object = list.selectedItem;
*
* }
* list.addEventListener( Event.CHANGE, list_changeHandler );</listing>
*
* @default null
*
* @see #selectedIndex
*/
public function get selectedItem():Object
{
if(!this._dataProvider || this._selectedIndex < 0 || this._selectedIndex >= this._dataProvider.length)
{
return null;
}
return this._dataProvider.getItemAt(this._selectedIndex);
}
/**
* @private
*/
public function set selectedItem(value:Object):void
{
if(!this._dataProvider)
{
this.selectedIndex = -1;
return;
}
this.selectedIndex = this._dataProvider.getItemIndex(value);
}
/**
* @private
*/
protected var _prompt:String;
/**
* Text displayed by the button sub-component when no items are
* currently selected.
*
* <p>In the following example, a prompt is given to the picker list
* and the selected item is cleared to display the prompt:</p>
*
* <listing version="3.0">
* list.prompt = "Select an Item";
* list.selectedIndex = -1;</listing>
*
* @default null
*/
public function get prompt():String
{
return this._prompt;
}
/**
* @private
*/
public function set prompt(value:String):void
{
if(this._prompt == value)
{
return;
}
this._prompt = value;
this.invalidate(INVALIDATION_FLAG_SELECTED);
}
/**
* @private
*/
protected var _labelField:String = "label";
/**
* The field in the selected item that contains the label text to be
* displayed by the picker list's button control. If the selected item
* does not have this field, and a <code>labelFunction</code> is not
* defined, then the picker list will default to calling
* <code>toString()</code> on the selected item. To omit the
* label completely, define a <code>labelFunction</code> that returns an
* empty string.
*
* <p><strong>Important:</strong> This value only affects the selected
* item displayed by the picker list's button control. It will <em>not</em>
* affect the label text of the pop-up list's item renderers.</p>
*
* <p>In the following example, the label field is changed:</p>
*
* <listing version="3.0">
* list.labelField = "text";</listing>
*
* @default "label"
*
* @see #labelFunction
*/
public function get labelField():String
{
return this._labelField;
}
/**
* @private
*/
public function set labelField(value:String):void
{
if(this._labelField == value)
{
return;
}
this._labelField = value;
this.invalidate(INVALIDATION_FLAG_DATA);
}
/**
* @private
*/
protected var _labelFunction:Function;
/**
* A function used to generate label text for the selected item
* displayed by the picker list's button control. If this
* function is not null, then the <code>labelField</code> will be
* ignored.
*
* <p><strong>Important:</strong> This value only affects the selected
* item displayed by the picker list's button control. It will <em>not</em>
* affect the label text of the pop-up list's item renderers.</p>
*
* <p>The function is expected to have the following signature:</p>
* <pre>function( item:Object ):String</pre>
*
* <p>All of the label fields and functions, ordered by priority:</p>
* <ol>
* <li><code>labelFunction</code></li>
* <li><code>labelField</code></li>
* </ol>
*
* <p>In the following example, the label field is changed:</p>
*
* <listing version="3.0">
* list.labelFunction = function( item:Object ):String
* {
* return item.firstName + " " + item.lastName;
* };</listing>
*
* @default null
*
* @see #labelField
*/
public function get labelFunction():Function
{
return this._labelFunction;
}
/**
* @private
*/
public function set labelFunction(value:Function):void
{
this._labelFunction = value;
this.invalidate(INVALIDATION_FLAG_DATA);
}
/**
* @private
*/
protected var _popUpContentManager:IPopUpContentManager;
/**
* A manager that handles the details of how to display the pop-up list.
*
* <p>In the following example, a pop-up content manager is provided:</p>
*
* <listing version="3.0">
* list.popUpContentManager = new CalloutPopUpContentManager();</listing>
*
* @default null
*/
public function get popUpContentManager():IPopUpContentManager
{
return this._popUpContentManager;
}
/**
* @private
*/
public function set popUpContentManager(value:IPopUpContentManager):void
{
if(this._popUpContentManager == value)
{
return;
}
if(this._popUpContentManager is EventDispatcher)
{
var dispatcher:EventDispatcher = EventDispatcher(this._popUpContentManager);
dispatcher.removeEventListener(Event.OPEN, popUpContentManager_openHandler);
dispatcher.removeEventListener(Event.CLOSE, popUpContentManager_closeHandler);
}
this._popUpContentManager = value;
if(this._popUpContentManager is EventDispatcher)
{
dispatcher = EventDispatcher(this._popUpContentManager);
dispatcher.addEventListener(Event.OPEN, popUpContentManager_openHandler);
dispatcher.addEventListener(Event.CLOSE, popUpContentManager_closeHandler);
}
this.invalidate(INVALIDATION_FLAG_STYLES);
}
/**
* @private
*/
protected var _typicalItemWidth:Number = NaN;
/**
* @private
*/
protected var _typicalItemHeight:Number = NaN;
/**
* @private
*/
protected var _typicalItem:Object = null;
/**
* Used to auto-size the list. If the list's width or height is NaN, the
* list will try to automatically pick an ideal size. This item is
* used in that process to create a sample item renderer.
*
* <p>The following example provides a typical item:</p>
*
* <listing version="3.0">
* list.typicalItem = { text: "A typical item", thumbnail: texture };
* list.itemRendererProperties.labelField = "text";
* list.itemRendererProperties.iconSourceField = "thumbnail";</listing>
*
* @default null
*/
public function get typicalItem():Object
{
return this._typicalItem;
}
/**
* @private
*/
public function set typicalItem(value:Object):void
{
if(this._typicalItem == value)
{
return;
}
this._typicalItem = value;
this._typicalItemWidth = NaN;
this._typicalItemHeight = NaN;
this.invalidate(INVALIDATION_FLAG_STYLES);
}
/**
* @private
*/
protected var _buttonFactory:Function;
/**
* A function used to generate the picker list's button sub-component.
* The button must be an instance of <code>Button</code>. This factory
* can be used to change properties on the button when it is first
* created. For instance, if you are skinning Feathers components
* without a theme, you might use this factory to set skins and other
* styles on the button.
*
* <p>The function should have the following signature:</p>
* <pre>function():Button</pre>
*
* <p>In the following example, a custom button factory is passed to the
* picker list:</p>
*
* <listing version="3.0">
* list.buttonFactory = function():Button
* {
* var button:Button = new Button();
* button.defaultSkin = new Image( upTexture );
* button.downSkin = new Image( downTexture );
* return button;
* };</listing>
*
* @default null
*
* @see feathers.controls.Button
* @see #buttonProperties
*/
public function get buttonFactory():Function
{
return this._buttonFactory;
}
/**
* @private
*/
public function set buttonFactory(value:Function):void
{
if(this._buttonFactory == value)
{
return;
}
this._buttonFactory = value;
this.invalidate(INVALIDATION_FLAG_BUTTON_FACTORY);
}
/**
* @private
*/
protected var _customButtonStyleName:String;
/**
* A style name to add to the picker list's button sub-component.
* Typically used by a theme to provide different styles to different
* picker lists.
*
* <p>In the following example, a custom button style name is passed to
* the picker list:</p>
*
* <listing version="3.0">
* list.customButtonStyleName = "my-custom-button";</listing>
*
* <p>In your theme, you can target this sub-component style name to
* provide different styles than the default:</p>
*
* <listing version="3.0">
* getStyleProviderForClass( Button ).setFunctionForStyleName( "my-custom-button", setCustomButtonStyles );</listing>
*
* @default null
*
* @see #DEFAULT_CHILD_STYLE_NAME_BUTTON
* @see feathers.core.FeathersControl#styleNameList
* @see #buttonFactory
* @see #buttonProperties
*/
public function get customButtonStyleName():String
{
return this._customButtonStyleName;
}
/**
* @private
*/
public function set customButtonStyleName(value:String):void
{
if(this._customButtonStyleName == value)
{
return;
}
this._customButtonStyleName = value;
this.invalidate(INVALIDATION_FLAG_BUTTON_FACTORY);
}
/**
* DEPRECATED: Replaced by <code>customButtonStyleName</code>.
*
* <p><strong>DEPRECATION WARNING:</strong> This property is deprecated
* starting with Feathers 2.1. It will be removed in a future version of
* Feathers according to the standard
* <a target="_top" href="../../../help/deprecation-policy.html">Feathers deprecation policy</a>.</p>
*
* @see #customButtonStyleName
*/
public function get customButtonName():String
{
return this.customButtonStyleName;
}
/**
* @private
*/
public function set customButtonName(value:String):void
{
this.customButtonStyleName = value;
}
/**
* @private
*/
protected var _buttonProperties:PropertyProxy;
/**
* An object that stores properties for the picker's button
* sub-component, and the properties will be passed down to the button
* when the picker validates. For a list of available
* properties, refer to
* <a href="Button.html"><code>feathers.controls.Button</code></a>.
*
* <p>If the subcomponent has its own subcomponents, their properties
* can be set too, using attribute <code>@</code> notation. For example,
* to set the skin on the thumb which is in a <code>SimpleScrollBar</code>,
* which is in a <code>List</code>, you can use the following syntax:</p>
* <pre>list.verticalScrollBarProperties.@thumbProperties.defaultSkin = new Image(texture);</pre>
*
* <p>Setting properties in a <code>buttonFactory</code> function
* instead of using <code>buttonProperties</code> will result in better
* performance.</p>
*
* <p>In the following example, the button properties are passed to the
* picker list:</p>
*
* <listing version="3.0">
* list.buttonProperties.defaultSkin = new Image( upTexture );
* list.buttonProperties.downSkin = new Image( downTexture );</listing>
*
* @default null
*
* @see #buttonFactory
* @see feathers.controls.Button
*/
public function get buttonProperties():Object
{
if(!this._buttonProperties)
{
this._buttonProperties = new PropertyProxy(childProperties_onChange);
}
return this._buttonProperties;
}
/**
* @private
*/
public function set buttonProperties(value:Object):void
{
if(this._buttonProperties == value)
{
return;
}
if(!value)
{
value = new PropertyProxy();
}
if(!(value is PropertyProxy))
{
var newValue:PropertyProxy = new PropertyProxy();
for(var propertyName:String in value)
{
newValue[propertyName] = value[propertyName];
}
value = newValue;
}
if(this._buttonProperties)
{
this._buttonProperties.removeOnChangeCallback(childProperties_onChange);
}
this._buttonProperties = PropertyProxy(value);
if(this._buttonProperties)
{
this._buttonProperties.addOnChangeCallback(childProperties_onChange);
}
this.invalidate(INVALIDATION_FLAG_STYLES);
}
/**
* @private
*/
protected var _listFactory:Function;
/**
* A function used to generate the picker list's pop-up list
* sub-component. The list must be an instance of <code>List</code>.
* This factory can be used to change properties on the list when it is
* first created. For instance, if you are skinning Feathers components
* without a theme, you might use this factory to set skins and other
* styles on the list.
*
* <p>The function should have the following signature:</p>
* <pre>function():List</pre>
*
* <p>In the following example, a custom list factory is passed to the
* picker list:</p>
*
* <listing version="3.0">
* list.listFactory = function():List
* {
* var popUpList:List = new List();
* popUpList.backgroundSkin = new Image( texture );
* return popUpList;
* };</listing>
*
* @default null
*
* @see feathers.controls.List
* @see #listProperties
*/
public function get listFactory():Function
{
return this._listFactory;
}
/**
* @private
*/
public function set listFactory(value:Function):void
{
if(this._listFactory == value)
{
return;
}
this._listFactory = value;
this.invalidate(INVALIDATION_FLAG_LIST_FACTORY);
}
/**
* @private
*/
protected var _customListStyleName:String;
/**
* A style name to add to the picker list's list sub-component.
* Typically used by a theme to provide different styles to different
* picker lists.
*
* <p>In the following example, a custom list style name is passed to the
* picker list:</p>
*
* <listing version="3.0">
* list.customListStyleName = "my-custom-list";</listing>
*
* <p>In your theme, you can target this sub-component style name to provide
* different styles than the default:</p>