try to fix some minor dropdown bugs
authorDave Stubbs <osm@randomjunk.co.uk>
Fri, 11 Sep 2009 01:08:18 +0000 (01:08 +0000)
committerDave Stubbs <osm@randomjunk.co.uk>
Fri, 11 Sep 2009 01:08:18 +0000 (01:08 +0000)
net/systemeD/potlatch2/mapfeatures/editors/Choice.as
net/systemeD/potlatch2/mapfeatures/editors/ChoiceComboBox.as
net/systemeD/potlatch2/mapfeatures/editors/ChoiceEditor.mxml
net/systemeD/potlatch2/mapfeatures/editors/SpeedEditor.mxml

index b501b19..635c95a 100644 (file)
@@ -4,50 +4,20 @@ package net.systemeD.potlatch2.mapfeatures.editors {
 
        public class Choice extends EventDispatcher {
 
-        private var _label:String = "";
-        private var _description:String = "";
-        private var _value:String = null;
-        private var _icon:String = null;
-        private var _match:RegExp = null;
-        
-        [Bindable(event="valueChange")]
-        public function get label():String { return _label; }
-
-        [Bindable(event="valueChange")]
-        public function get description():String { return _description; }
-
-        [Bindable(event="valueChange")]
-        public function get value():String { return _value; }
+        [Bindable]
+        public var label:String = "";
+        [Bindable]
+        public var description:String = "";
+        [Bindable]
+        public var value:String = null;
+        [Bindable]
+        public var icon:String = null;
 
-        [Bindable(event="valueChange")]
-        public function get icon():String { return _icon; }
-
-        public function set label(l:String):void {
-            _label = l;
-            dispatchEvent(new Event("valueChange"));
-        }
-        
-        public function set description(l:String):void {
-            _description = l;
-            dispatchEvent(new Event("valueChange"));
-        }
-        
-        public function set value(l:String):void {
-            _value = l;
-            dispatchEvent(new Event("valueChange"));
-        }
-        
-        public function set icon(l:String):void {
-            _icon = l;
-            dispatchEvent(new Event("valueChange"));
-        }
+        private var _match:RegExp = null;
         
         public function isTagMatch(tagValue:String):Boolean {
             if ( _match == null )
-                return tagValue == _value;
-            //_match.lastIndex = 0;
-            //var result:Object = _match.exec(tagValue);
-            //return result != null && result.index == 0 && _match.lastIndex == tagValue.length;
+                return tagValue == value;
             return _match.test(tagValue);
         }
         
index ef8c094..e9d4e27 100644 (file)
@@ -22,7 +22,7 @@ package net.systemeD.potlatch2.mapfeatures.editors {
 
                                 //create a new itemRenderer to use in place of the text input
                                 textInputReplacement = itemRenderer.newInstance();
-                                IDataRenderer(textInputReplacement).data = {text: "banana"};
+                                IDataRenderer(textInputReplacement).data = selectedItem;
                                 textInputReplacement.mouseChildren = false;
                                 textInputReplacement.mouseEnabled = false;
                                 addChild(textInputReplacement);
index df8ecbd..fa03e3a 100644 (file)
       private var _unknownChoice:Choice = null;
 
       [Bindable(event="factory_set")]
-      private function get choices():ArrayCollection {
+      protected function get choices():ArrayCollection {
           if ( _choices == null ) {
-              _choices = new ArrayCollection(ChoiceEditorFactory(_factory).choices);
+              _choices = new ArrayCollection();
+              for each ( var choice:Choice in ChoiceEditorFactory(_factory).choices )
+                  _choices.addItem(choice);
               _choices.addItem(createUnsetChoice());
           }
           return _choices;
       }
       
       [Bindable(event="tag_changed")]
-      private function get selectFromTag():Object {
+      protected function get selectFromTag():Object {
           var tagValue:String = value;
           for each(var choice:Choice in choices) {
               if ( choice.isTagMatch(tagValue) )
index d5180f2..37a81f0 100644 (file)
       private var _unknownChoice:SpeedChoice = null;
 
       [Bindable(event="factory_set")]
-      private function get choices():ArrayCollection {
+      protected function get choices():ArrayCollection {
           if ( _choices == null ) {
               _choices = new ArrayCollection();
               for each(var sp:String in
                   ["5mph", "10mph", "15mph", "20mph", "30mph", "40mph", "50mph", "60mph","70mph",
                    "10", "20", "50", "60", "90", "100", "110", "130"])
                   _choices.addItem(new SpeedChoice(sp));
+              _choices.addItem(new SpeedChoice(null));
           }
           return _choices;
       }
       
       [Bindable(event="tag_changed")]
-      private function get selectFromTag():Object {
+      protected function get selectFromTag():Object {
+          if ( _entity == null )
+              return new SpeedChoice(null);
+          
           var tagValue:String = value;
           for each(var choice:SpeedChoice in choices) {
               if ( choice.isTagMatch(tagValue) )