]> git.openstreetmap.org Git - potlatch2.git/commitdiff
Fix HTML rendering in drop-downs
authorRichard Fairhurst <richard@systemeD.net>
Thu, 15 Sep 2011 19:53:13 +0000 (20:53 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Thu, 15 Sep 2011 19:53:13 +0000 (20:53 +0100)
net/systemeD/potlatch2/mapfeatures/editors/ChoiceEditor.mxml

index 5f1c9084142cc16cfd1abe9614a317f6509daf85..cd7489d79567bf6da705d8b40d15e7278b60149f 100644 (file)
         <fx:Component>
         <mx:HBox toolTip="{data.description}" horizontalScrollPolicy="off">
           <mx:Image source="{Choice(data).icon}"/>
-          <mx:Label htmlText="{data.label}"/>
+          <mx:Label htmlText="{getStyledLabel(Choice(data))}"/>
+                       <fx:Script><![CDATA[
+                             public function getStyledLabel(choice:Choice):String {
+                                 if (choice.value==null) return "<font color='#a0a0a0'><i>"+choice.label+"</i></font>";
+                                 return choice.label;
+                                 }
+                       ]]></fx:Script>
         </mx:HBox>
         </fx:Component>
       </s:itemRenderer>
       private var _choices:ArrayCollection = null;
       private var _unknownChoice:Choice = null;
 
-      // ** FIXME:
-      // currently the raw htmlText for the selected item is shown.
-      // see http://stackoverflow.com/questions/269773/flex-custom-item-renderer-for-the-displayed-item-in-the-combobox/280859#280859
-      // (via http://stackoverflow.com/questions/4051822/flex-itemrenderer-issue-with-dropdown-control)
-
       [Bindable(event="factory_set")]
       protected function get choices():ArrayCollection {
           var dummy:String=_factory.key;               // otherwise _factory is null, for some not yet discovered reason.
           
           return _unknownChoice;
       }
-      
+
       private function createUnsetChoice():Choice {
           var choice:Choice = new Choice();
           choice.icon = null;
           choice.description = "Field not set";
-          choice.label = "<font color='#a0a0a0'><i>Unset</i></font>";
+          choice.label = "Unset";
           choice.value = null;
           return choice;
       }