first go at specialised tag editors
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / editors / ChoiceEditor.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <edit:SingleTagEditor
3         xmlns:mx="http://www.adobe.com/2006/mxml" 
4         xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
5         verticalGap="0"
6         width="100%"
7         toolTip="{fieldDescription}">
8
9   <mx:Label text="{fieldName}:"/>
10   <edit:ChoiceComboBox id="inputBox" dataProvider="{choices}" selectedItem="{selectFromTag}"
11       width="100%" change="value = inputBox.selectedItem.value"
12       open="inputBox.dropdown.variableRowHeight = true">
13       <edit:itemRenderer>
14         <mx:Component>
15         <mx:HBox toolTip="{data.description}">
16           <mx:Image source="{data.icon}"/>
17           <mx:Label text="{data.label}"/>
18         </mx:HBox>
19         </mx:Component>
20       </edit:itemRenderer>
21   </edit:ChoiceComboBox>
22
23   <mx:Script><![CDATA[
24
25       [Bindable(event="factory_set")]
26       private function get choices():Array {
27           return ChoiceEditorFactory(_factory).choices;
28       }
29       
30       [Bindable(event="tag_changed")]
31       private function get selectFromTag():Object {
32           var tagValue:String = value;
33           for each(var choice:Object in choices) {
34               if ( choice.value == tagValue )
35                   return choice;
36           }
37           
38           inputBox.prompt = tagValue == null ? "" : tagValue;
39           return null;
40       }
41       
42   ]]></mx:Script>
43 </edit:SingleTagEditor>
44