You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/04/12 23:00:41 UTC
[royale-asjs] 07/09: MX combobox
This is an automated email from the ASF dual-hosted git repository.
aharui pushed a commit to branch feature/MXRoyale
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 6943f02340951f5a3effee2dbd50584d2e1bee2e
Author: Alex Harui <ah...@apache.org>
AuthorDate: Thu Apr 12 15:58:18 2018 -0700
MX combobox
---
.../MXRoyale/src/main/resources/defaults.css | 8 +
.../src/main/resources/mx-royale-manifest.xml | 1 +
.../src/main/royale/mx/controls/ComboBase.as | 803 ++++++++++++++++++++
.../src/main/royale/mx/controls/ComboBox.as | 817 +++++++++++++++++++++
4 files changed, 1629 insertions(+)
diff --git a/frameworks/projects/MXRoyale/src/main/resources/defaults.css b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
index 122a1ed..4878cab 100644
--- a/frameworks/projects/MXRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
@@ -51,6 +51,14 @@ CheckBox
IBeadModel: ClassReference("org.apache.royale.html.beads.models.ToggleButtonModel");
}
+ComboBox
+{
+ IBeadModel: ClassReference("org.apache.royale.html.beads.models.ComboBoxModel");
+ IBeadView: ClassReference("org.apache.royale.html.beads.ComboBoxView");
+ IBeadController: ClassReference("org.apache.royale.html.beads.controllers.ComboBoxController");
+ IPopUp: ClassReference("org.apache.royale.html.supportClasses.ComboBoxList");
+}
+
Container
{
IBeadView: ClassReference("org.apache.royale.html.beads.ContainerView");
diff --git a/frameworks/projects/MXRoyale/src/main/resources/mx-royale-manifest.xml b/frameworks/projects/MXRoyale/src/main/resources/mx-royale-manifest.xml
index aee94b2..df888d0 100644
--- a/frameworks/projects/MXRoyale/src/main/resources/mx-royale-manifest.xml
+++ b/frameworks/projects/MXRoyale/src/main/resources/mx-royale-manifest.xml
@@ -24,6 +24,7 @@
<component id="Application" class="mx.core.Application" />
<component id="Button" class="mx.controls.Button" />
<component id="CheckBox" class="mx.controls.CheckBox" />
+ <component id="ComboBox" class="mx.controls.ComboBox" />
<component id="DateChooser" class="mx.controls.DateChooser" />
<component id="Image" class="mx.controls.Image" />
<component id="Label" class="mx.controls.Label" />
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ComboBase.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ComboBase.as
new file mode 100644
index 0000000..043f906
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ComboBase.as
@@ -0,0 +1,803 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.controls
+{
+COMPILE::JS
+{
+ import goog.DEBUG;
+}
+COMPILE::SWF
+{
+ import flash.display.InteractiveObject;
+}
+/*
+import flash.display.DisplayObject;
+import flash.events.Event;
+import flash.events.FocusEvent;
+import flash.events.KeyboardEvent;
+import flash.events.MouseEvent;
+import flash.events.TextEvent;
+import mx.collections.ArrayCollection;
+import mx.collections.CursorBookmark;
+import mx.collections.ICollectionView;
+import mx.collections.IList;
+import mx.collections.IViewCursor;
+import mx.collections.ListCollectionView;
+import mx.collections.XMLListCollection;
+import mx.core.EdgeMetrics;
+import mx.core.FlexVersion;
+import mx.core.IFlexDisplayObject;
+import mx.core.IIMESupport;
+import mx.core.IRectangularBorder;
+import mx.core.IUITextField;
+import mx.core.UITextField;
+import mx.events.CollectionEvent;
+import mx.events.CollectionEventKind;
+import mx.events.FlexEvent;
+import mx.managers.IFocusManager;
+import mx.styles.ISimpleStyleClient;
+import mx.styles.StyleProxy;
+import mx.utils.UIDUtil;
+*/
+import mx.core.ITextInput;
+import mx.core.UIComponent;
+import mx.core.mx_internal;
+use namespace mx_internal;
+
+import mx.managers.IFocusManagerComponent;
+
+import org.apache.royale.core.IComboBoxModel;
+import org.apache.royale.html.TextInput;
+import org.apache.royale.html.beads.IComboBoxView;
+import org.apache.royale.core.IComboBoxModel;
+import org.apache.royale.core.IUIBase;
+import mx.events.FlexEvent;
+
+/**
+ * The alpha of the content background for this component.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+//[Style(name="contentBackgroundAlpha", type="Number", inherit="yes", theme="spark")]
+
+/**
+ * Color of the content area of the component.
+ *
+ * @default 0xFFFFFF
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+//[Style(name="contentBackgroundColor", type="uint", format="Color", inherit="yes", theme="spark")]
+
+/**
+ * Color of focus ring when the component is in focus
+ *
+ * @default 0x70B2EE
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+//[Style(name="focusColor", type="uint", format="Color", inherit="yes", theme="spark")]
+
+/**
+ * Color of any symbol of a component. Examples include the check mark of a CheckBox or
+ * the arrow of a ScrollBar button.
+ *
+ * @default 0x000000
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+//[Style(name="symbolColor", type="uint", format="Color", inherit="yes", theme="spark")]
+
+/**
+ * Name of the class to use as the default skin for the background and border.
+ * For the ComboBase class, there is no default value.
+ * For the ComboBox class, the default value is the ComboBoxArrowSkin class.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="skin", type="Class", inherit="no", states=" up, over, down, disabled, editableUp, editableOver, editableDown, editableDisabled")]
+
+/**
+ * Name of the class to use as the skin for the background and border
+ * when the mouse is not over the control.
+ * For the ComboBase class, there is no default value.
+ * For the ComboBox class, the default value is the ComboBoxArrowSkin class.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="upSkin", type="Class", inherit="no")]
+
+/**
+ * Name of the class to use as the skin for the background and border
+ * when the mouse is over the control.
+ * For the ComboBase class, there is no default value.
+ * For the ComboBox class, the default value is the ComboBoxArrowSkin class.
+ * For the ColorPicker class, the default value is the ColorPickerSkin class.
+ * For the DateField class, the default value is the ScrollArrowDownSkin class.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="overSkin", type="Class", inherit="no")]
+
+/**
+ * Name of the class to use as the skin for the background and border
+ * when the user holds down the mouse button.
+ * For the ComboBase class, there is no default value.
+ * For the ComboBox class, the default value is the ComboBoxArrowSkin class.
+ * For the ColorPicker class, the default value is the ColorPickerSkin class.
+ * For the DateField class, the default value is the ScrollArrowDownSkin class.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="downSkin", type="Class", inherit="no")]
+
+/**
+ * Name of the class to use as the skin for the background and border
+ * when the control is disabled.
+ * For the ComboBase class, there is no default value.
+ * For the ComboBox class, the default value is the ComboBoxArrowSkin class.
+ * For the ColorPicker class, the default value is the ColorPickerSkin class.
+ * For the DateField class, the default value is the ScrollArrowDownSkin class.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="disabledSkin", type="Class", inherit="no")]
+
+/**
+ * Name of the class to use as the skin for the background and border
+ * when the <code>editable</code>
+ * property is <code>true</code>. This skin is only used by the ComboBox class.
+ * For the ComboBase class, there is no default value.
+ * For the ComboBox class, the default value is the ComboBoxArrowSkin class.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="editableSkin", type="Class", inherit="no")]
+
+/**
+ * Name of the class to use as the skin for the background and border
+ * when the mouse is not over the control, and the <code>editable</code>
+ * property is <code>true</code>. This skin is only used by the ComboBox class.
+ * For the ComboBase class, there is no default value.
+ * For the ComboBox class, the default value is the ComboBoxArrowSkin class.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="editableUpSkin", type="Class", inherit="no")]
+
+/**
+ * Name of the class to use as the skin for the background and border
+ * when the mouse is over the control, and the <code>editable</code>
+ * property is <code>true</code>. This skin is only used by the ComboBox class.
+ * For the ComboBase class, there is no default value.
+ * For the ComboBox class, the default value is the ComboBoxArrowSkin class.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="editableOverSkin", type="Class", inherit="no")]
+
+/**
+ * Name of the class to use as the skin for the background and border
+ * when the user holds down the mouse button, and the <code>editable</code>
+ * property is <code>true</code>. This skin is only used by the ComboBox class.
+ * For the ComboBase class, there is no default value.
+ * For the ComboBox class, the default value is the ComboBoxArrowSkin class.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="editableDownSkin", type="Class", inherit="no")]
+
+/**
+ * Name of the class to use as the skin for the background and border
+ * when the control is disabled, and the <code>editable</code>
+ * property is <code>true</code>. This skin is only used by the ComboBox class.
+ * For the ComboBase class, there is no default value.
+ * For the ComboBox class, the default value is the ComboBoxArrowSkin class.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="editableDisabledSkin", type="Class", inherit="no")]
+
+/**
+ * The class implementing ITextInput that is used by this component
+ * to input text.
+ *
+ * <p>It can be set to either the mx.core.TextInput class
+ * (to use the classic Halo TextInput control)
+ * or the mx.controls.MXFTETextInput class
+ * (to use the Spark TextInput component based on the Text Layout Framework
+ * to get improved text rendering, including bidirectional layout).</p>
+ *
+ * @default mx.controls.TextInput
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+//[Style(name="textInputClass", type="Class", inherit="no")]
+
+/**
+ * The style declaration for the internal TextInput subcomponent
+ * that displays the current selection.
+ * If no value is specified, then the TextInput subcomponent uses
+ * the default text styles defined by the ComboBase class.
+ *
+ * @default ""
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="textInputStyleName", type="String", inherit="no")]
+//--------------------------------------
+// Other metadata
+//--------------------------------------
+
+[AccessibilityClass(implementation="mx.accessibility.ComboBaseAccImpl")]
+
+/**
+ * The ComboBase class is the base class for controls that display text in a
+ * text field and have a button that causes a drop-down list to appear where
+ * the user can choose which text to display.
+ * The ComboBase class is not used directly as an MXML tag.
+ *
+ * @mxml
+ *
+ * <p>The <code><mx:ComboBase></code> tag inherits all the tag attributes
+ * of its superclass, and adds the following tag attributes:</p>
+ *
+ * <pre>
+ * <<i>mx:tagname</i>
+ * <b>Properties</b>
+ * dataProvider="null"
+ * editable="false|true"
+ * imeMode="null"
+ * restrict="null"
+ * selectedIndex="-1"
+ * selectedItem="null"
+ * text=""
+ *
+ * <b>Styles</b>
+ * disabledSkin="<i>Depends on class</i>"
+ * downSkin="<i>Depends on class</i>"
+ * editableDisabledSkin="<i>Depends on class</i>"
+ * editableDownSkin="<i>Depends on class</i>"
+ * editableOverSkin="<i>Depends on class</i>"
+ * editableUpSkin="<i>Depends on class</i>"
+ * overSkin="<i>Depends on class</i>"
+ * textInputStyleName=""
+ * upSkin="<i>Depends on class</i>"
+ *
+ * />
+ * </pre>
+ *
+ * @see mx.controls.Button
+ * @see mx.controls.TextInput
+ * @see mx.collections.ICollectionView
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+public class ComboBase extends UIComponent implements /*IIMESupport,*/ IFocusManagerComponent
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function ComboBase()
+ {
+ super();
+
+ COMPILE::SWF
+ {
+ tabEnabled = true;
+ tabFocusEnabled = true;
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+
+ /**
+ * @private
+ * The internal Button property that causes the drop-down list to appear.
+ * @royalesuppresspublicvarwarning
+ */
+ mx_internal var downArrowButton:Button;
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden properties
+ //
+ //--------------------------------------------------------------------------
+
+
+ //----------------------------------
+ // enabled
+ //----------------------------------
+
+ /**
+ * @private
+ * Storage for enabled property.
+ */
+ private var _enabled:Boolean = false;
+
+ /**
+ * @private
+ */
+ private var enabledChanged:Boolean = false;
+
+ [Inspectable(category="General", enumeration="true,false", defaultValue="true")]
+
+ /**
+ * @private
+ */
+ override public function get enabled():Boolean
+ {
+ if (GOOG::DEBUG)
+ trace("ComboBox.enabled not implemented");
+ return true;
+ }
+
+ override public function set enabled(value:Boolean):void
+ {
+ if (GOOG::DEBUG)
+ trace("ComboBox.enabled not implemented");
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+
+ //----------------------------------
+ // dataProvider
+ //----------------------------------
+
+ [Bindable("collectionChange")]
+ [Inspectable(category="Data")]
+
+ /**
+ * The set of items this component displays. This property is of type
+ * Object because the derived classes can handle a variety of data
+ * types such as Arrays, XML, ICollectionViews, and other classes. All
+ * are converted into an ICollectionView and that ICollectionView is
+ * returned if you get the value of this property; you will not get the
+ * value you set if it was not an ICollectionView.
+ *
+ * <p>Setting this property will adjust the <code>selectedIndex</code>
+ * property (and therefore the <code>selectedItem</code> property) if
+ * the <code>selectedIndex</code> property has not otherwise been set.
+ * If there is no <code>prompt</code> property, the <code>selectedIndex</code>
+ * property will be set to 0; otherwise it will remain at -1,
+ * the index used for the prompt string.
+ * If the <code>selectedIndex</code> property has been set and
+ * it is out of range of the new data provider, unexpected behavior is
+ * likely to occur.</p>
+ *
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function get dataProvider():Object
+ {
+ return IComboBoxModel(model).dataProvider;
+ }
+
+ /**
+ * @private
+ */
+ public function set dataProvider(value:Object):void
+ {
+ IComboBoxModel(model).dataProvider = value;
+ if (value && IComboBoxModel(model).selectedIndex == -1)
+ IComboBoxModel(model).selectedIndex = 0;
+ }
+
+ //----------------------------------
+ // editable
+ //----------------------------------
+
+ [Bindable("editableChanged")]
+ [Inspectable(category="General", defaultValue="false")]
+
+ /**
+ * A flag that indicates whether the control is editable,
+ * which lets the user directly type entries that are not specified
+ * in the dataProvider, or not editable, which requires the user select
+ * from the items in the dataProvider.
+ *
+ * <p>If <code>true</code> keyboard input will be entered in the
+ * editable text field; otherwise it will be used as shortcuts to
+ * select items in the dataProvider.</p>
+ *
+ * @default false.
+ * This property is ignored by the DateField control.
+ *
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function get editable():Boolean
+ {
+ if (GOOG::DEBUG)
+ trace("ComboBox.editable not implemented");
+ return true;
+ }
+
+ /**
+ * @private
+ */
+ public function set editable(value:Boolean):void
+ {
+ if (GOOG::DEBUG)
+ trace("ComboBox.editable not implemented");
+ }
+
+
+ //----------------------------------
+ // imeMode
+ //----------------------------------
+
+ /**
+ * @copy mx.controls.TextInput#imeMode
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ **/
+ public function get imeMode():String
+ {
+ if (GOOG::DEBUG)
+ trace("ComboBox.imeMode not implemented");
+ return "";
+ }
+
+ /**
+ * @private
+ */
+ public function set imeMode(value:String):void
+ {
+ if (GOOG::DEBUG)
+ trace("ComboBox.imeMode not implemented");
+ }
+
+ //----------------------------------
+ // restrict
+ //----------------------------------
+
+ /**
+ * Set of characters that a user can or cannot enter into the text field.
+ *
+ * @default null
+ *
+ * @see flash.text.TextField#restrict
+ *
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function get restrict():String
+ {
+ if (GOOG::DEBUG)
+ trace("ComboBox.restrict not implemented");
+ return "";
+ }
+
+ /**
+ * @private
+ */
+ public function set restrict(value:String):void
+ {
+ if (GOOG::DEBUG)
+ trace("ComboBox.restrict not implemented");
+ }
+
+ //----------------------------------
+ // selectedIndex
+ //----------------------------------
+
+ [Bindable("change")]
+ [Bindable("valueCommit")]
+ [Inspectable(category="General", defaultValue="-1")]
+
+ /**
+ * The index in the data provider of the selected item.
+ * If there is a <code>prompt</code> property, the <code>selectedIndex</code>
+ * value can be set to -1 to show the prompt.
+ * If there is no <code>prompt</code>, property then <code>selectedIndex</code>
+ * will be set to 0 once a <code>dataProvider</code> is set.
+ *
+ * <p>If the ComboBox control is editable, the <code>selectedIndex</code>
+ * property is -1 if the user types any text
+ * into the text field.</p>
+ *
+ * <p>Unlike many other Flex properties that are invalidating (setting
+ * them does not have an immediate effect), the <code>selectedIndex</code> and
+ * <code>selectedItem</code> properties are synchronous; setting one immediately
+ * affects the other.</p>
+ *
+ * @default -1
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function get selectedIndex():int
+ {
+ return IComboBoxModel(model).selectedIndex;
+ }
+
+ /**
+ * @private
+ */
+ public function set selectedIndex(value:int):void
+ {
+ IComboBoxModel(model).selectedIndex = value;
+
+ }
+
+
+ //----------------------------------
+ // selectedItem
+ //----------------------------------
+
+ [Bindable("change")]
+ [Bindable("valueCommit")]
+ [Inspectable(category="General", defaultValue="null")]
+
+ /**
+ * The item in the data provider at the selectedIndex.
+ *
+ * <p>If the data is an object or class instance, modifying
+ * properties in the object or instance modifies the
+ * <code>dataProvider</code> object but may not update the views
+ * unless the instance is Bindable or implements IPropertyChangeNotifier
+ * or a call to dataProvider.itemUpdated() occurs.</p>
+ *
+ * Setting the <code>selectedItem</code> property causes the
+ * ComboBox control to select that item (display it in the text field and
+ * set the <code>selectedIndex</code>) if it exists in the data provider.
+ * If the ComboBox control is editable, the <code>selectedItem</code>
+ * property is <code>null</code> if the user types any text
+ * into the text field.
+ *
+ * <p>Unlike many other Flex properties that are invalidating (setting
+ * them does not have an immediate effect), <code>selectedIndex</code> and
+ * <code>selectedItem</code> are synchronous; setting one immediately
+ * affects the other.</p>
+ *
+ * @default null;
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function get selectedItem():Object
+ {
+ return IComboBoxModel(model).selectedItem;
+ }
+
+ /**
+ * @private
+ */
+ public function set selectedItem(value:Object):void
+ {
+ IComboBoxModel(model).selectedItem = value;
+ }
+
+ //----------------------------------
+ // text
+ //----------------------------------
+
+ [Bindable("collectionChange")]
+ [Bindable("valueCommit")]
+ [Inspectable(category="General", defaultValue="")]
+ [NonCommittingChangeEvent("change")]
+
+ /**
+ * Contents of the text field. If the control is non-editable
+ * setting this property has no effect. If the control is editable,
+ * setting this property sets the contents of the text field.
+ *
+ * @default ""
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function get text():String
+ {
+ return ((view as IComboBoxView).textInputField as org.apache.royale.html.TextInput).text;
+ }
+
+ /**
+ * @private
+ */
+ public function set text(value:String):void
+ {
+ if (GOOG::DEBUG)
+ trace("ComboBox.text not implemented");
+ }
+
+ //----------------------------------
+ // textInput
+ //----------------------------------
+
+ /**
+ * The internal TextInput subcomponent that displays
+ * the current selection.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ protected function get textInput():Object
+ {
+ return (view as IComboBoxView).textInputField;
+ }
+
+
+ //----------------------------------
+ // textInputStyleFilters
+ //----------------------------------
+
+ /**
+ * The set of styles to pass from the ComboBase to the text input.
+ * These styles are ignored if you set
+ * the <code>textInputStyleName</code> style property.
+ * @see mx.styles.StyleProxy
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ protected function get textInputStyleFilters():Object
+ {
+ return _textInputStyleFilters;
+ }
+
+ private static var _textInputStyleFilters:Object =
+ {
+ "backgroundAlpha" : "backgroundAlpha",
+ "backgroundColor" : "backgroundColor",
+ "backgroundImage" : "backgroundImage",
+ "backgroundDisabledColor" : "backgroundDisabledColor",
+ "backgroundSize" : "backgroundSize",
+ "borderAlpha" : "borderAlpha",
+ "borderColor" : "borderColor",
+ "borderSides" : "borderSides",
+ "borderStyle" : "borderStyle",
+ "borderThickness" : "borderThickness",
+ "dropShadowColor" : "dropShadowColor",
+ "dropShadowEnabled" : "dropShadowEnabled",
+ "embedFonts" : "embedFonts",
+ "focusAlpha" : "focusAlpha",
+ "focusBlendMode" : "focusBlendMode",
+ "focusRoundedCorners" : "focusRoundedCorners",
+ "focusThickness" : "focusThickness",
+ "leading" : "leading",
+ "paddingLeft" : "paddingLeft",
+ "paddingRight" : "paddingRight",
+ "shadowDirection" : "shadowDirection",
+ "shadowDistance" : "shadowDistance",
+ "textDecoration" : "textDecoration"
+ };
+
+
+ /**
+ * @private
+ */
+ override public function setFocus():void
+ {
+ if (textInput && editable)
+ {
+ COMPILE::SWF
+ {
+ stage.focus = textInput as InteractiveObject;
+ }
+ COMPILE::JS
+ {
+ (textInput as IUIBase).element.focus();
+ }
+ }
+ else
+ super.setFocus();
+ }
+
+}
+
+}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ComboBox.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ComboBox.as
new file mode 100644
index 0000000..1f204d6
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ComboBox.as
@@ -0,0 +1,817 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.controls
+{
+import org.apache.royale.html.beads.IComboBoxView;
+
+COMPILE::SWF
+{
+}
+
+/*
+import flash.display.DisplayObject;
+import flash.events.Event;
+import flash.events.FocusEvent;
+import flash.events.KeyboardEvent;
+import flash.events.MouseEvent;
+import flash.geom.Matrix;
+import flash.geom.Point;
+import flash.geom.Rectangle;
+import flash.text.TextLineMetrics;
+import flash.ui.Keyboard;
+*/
+
+/*
+import mx.collections.ArrayCollection;
+import mx.collections.CursorBookmark;
+import mx.controls.dataGridClasses.DataGridListData;
+import mx.controls.listClasses.BaseListData;
+import mx.controls.listClasses.IDropInListItemRenderer;
+import mx.controls.listClasses.IListItemRenderer;
+import mx.controls.listClasses.ListBase;
+import mx.controls.listClasses.ListData;
+import mx.core.ClassFactory;
+import mx.core.EdgeMetrics;
+import mx.core.IDataRenderer;
+import mx.core.IFactory;
+import mx.core.LayoutDirection;
+import mx.core.ScrollPolicy;
+import mx.core.UIComponent;
+import mx.core.UIComponentGlobals;
+import mx.core.mx_internal;
+import mx.effects.Tween;
+import mx.events.CollectionEvent;
+import mx.events.CollectionEventKind;
+import mx.events.DropdownEvent;
+import mx.events.FlexEvent;
+import mx.events.FlexMouseEvent;
+import mx.events.InterManagerRequest;
+import mx.events.ListEvent;
+import mx.events.SandboxMouseEvent;
+import mx.events.ScrollEvent;
+import mx.events.ScrollEventDetail;
+import mx.managers.ISystemManager;
+import mx.managers.PopUpManager;
+import mx.styles.CSSStyleDeclaration;
+import mx.utils.MatrixUtil;
+
+use namespace mx_internal;
+*/
+
+//--------------------------------------
+// Events
+//--------------------------------------
+
+/**
+ * Dispatched when the ComboBox contents changes as a result of user
+ * interaction, when the <code>selectedIndex</code> or
+ * <code>selectedItem</code> property changes, and, if the ComboBox control
+ * is editable, each time a keystroke is entered in the box.
+ *
+ * @eventType mx.events.ListEvent.CHANGE
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+[Event(name="change", type="mx.events.ListEvent")]
+
+/**
+ * Dispatched when the drop-down list is dismissed for any reason such when
+ * the user:
+ * <ul>
+ * <li>selects an item in the drop-down list</li>
+ * <li>clicks outside of the drop-down list</li>
+ * <li>clicks the drop-down button while the drop-down list is
+ * displayed</li>
+ * <li>presses the ESC key while the drop-down list is displayed</li>
+ * </ul>
+ *
+ * @eventType mx.events.DropdownEvent.CLOSE
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+[Event(name="close", type="mx.events.DropdownEvent")]
+
+/**
+ * Dispatched when the <code>data</code> property changes.
+ *
+ * <p>When you use a component as an item renderer,
+ * the <code>data</code> property contains an item from the
+ * dataProvider.
+ * You can listen for this event and update the component
+ * when the <code>data</code> property changes.</p>
+ *
+ * @eventType mx.events.FlexEvent.DATA_CHANGE
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+[Event(name="dataChange", type="mx.events.FlexEvent")]
+
+/**
+ * Dispatched if the <code>editable</code> property
+ * is set to <code>true</code> and the user presses the Enter key
+ * while typing in the editable text field.
+ *
+ * @eventType mx.events.FlexEvent.ENTER
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+[Event(name="enter", type="mx.events.FlexEvent")]
+
+/**
+ * Dispatched when user rolls the mouse out of a drop-down list item.
+ * The event object's <code>target</code> property contains a reference
+ * to the ComboBox and not the drop-down list.
+ *
+ * @eventType mx.events.ListEvent.ITEM_ROLL_OUT
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+[Event(name="itemRollOut", type="mx.events.ListEvent")]
+
+/**
+ * Dispatched when the user rolls the mouse over a drop-down list item.
+ * The event object's <code>target</code> property contains a reference
+ * to the ComboBox and not the drop-down list.
+ *
+ * @eventType mx.events.ListEvent.ITEM_ROLL_OVER
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+[Event(name="itemRollOver", type="mx.events.ListEvent")]
+
+/**
+ * Dispatched when the user clicks the drop-down button
+ * to display the drop-down list. It is also dispatched if the user
+ * uses the keyboard and types Ctrl-Down to open the drop-down.
+ *
+ * @eventType mx.events.DropdownEvent.OPEN
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+[Event(name="open", type="mx.events.DropdownEvent")]
+
+/**
+ * Dispatched when the user scrolls the ComboBox control's drop-down list.
+ *
+ * @eventType mx.events.ScrollEvent.SCROLL
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+[Event(name="scroll", type="mx.events.ScrollEvent")]
+
+//--------------------------------------
+// Styles
+//--------------------------------------
+
+/*
+include "../styles/metadata/FocusStyles.as"
+include "../styles/metadata/IconColorStyles.as"
+include "../styles/metadata/LeadingStyle.as"
+include "../styles/metadata/PaddingStyles.as"
+include "../styles/metadata/SkinStyles.as"
+include "../styles/metadata/TextStyles.as"
+*/
+
+/**
+ * The set of BackgroundColors for drop-down list rows in an alternating
+ * pattern.
+ * Value can be an Array of two of more colors.
+ * If <code>undefined</code> then the rows will use the drop-down list's
+ * backgroundColor style.
+ *
+ * @default undefined
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="alternatingItemColors", type="Array", arrayType="uint", format="Color", inherit="yes")]
+
+/**
+ * Width of the arrow button in pixels.
+ *
+ * The default value for the Halo theme is 22.
+ * The default value for the Spark theme is 18.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="arrowButtonWidth", type="Number", format="Length", inherit="no")]
+
+/**
+ * The thickness of the border of the drop-down list, in pixels.
+ * This value is overridden if you define
+ * <code>borderThickness</code> when setting the
+ * <code>dropdownStyleName</code> CSSStyleDeclaration.
+ *
+ * @default 1
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="borderThickness", type="Number", format="Length", inherit="no")]
+
+/**
+ * The length of the transition when the drop-down list closes, in milliseconds.
+ * The default transition has the drop-down slide up into the ComboBox.
+ *
+ * The default value for the Halo theme is 250.
+ * The default value for the Spark theme is 50.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="closeDuration", type="Number", format="Time", inherit="no")]
+
+/**
+ * An easing function to control the close transition. Easing functions can
+ * be used to control the acceleration and deceleration of the transition.
+ *
+ * @default undefined
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="closeEasingFunction", type="Function", inherit="no")]
+
+/**
+ * The color of the border of the ComboBox. If <code>undefined</code>
+ * the drop-down list will use its normal borderColor style. This style
+ * is used by the validators to show the ComboBox in an error state.
+ *
+ * @default undefined
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="dropdownBorderColor", type="uint", format="Color", inherit="yes", theme="halo")]
+
+/**
+ * The name of a CSSStyleDeclaration to be used by the drop-down list. This
+ * allows you to control the appearance of the drop-down list or its item
+ * renderers.
+ *
+ * [deprecated]
+ *
+ * @default "comboDropDown"
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="dropDownStyleName", type="String", inherit="no", deprecatedReplacement="dropdownStyleName")]
+
+/**
+ * The name of a CSSStyleDeclaration to be used by the drop-down list. This
+ * allows you to control the appearance of the drop-down list or its item
+ * renderers.
+ *
+ * @default "comboDropdown"
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="dropdownStyleName", type="String", inherit="no")]
+
+/**
+ * Length of the transition when the drop-down list opens, in milliseconds.
+ * The default transition has the drop-down slide down from the ComboBox.
+ *
+ * The default value for the Halo theme is 250.
+ * The default value for the Spark theme is 0.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="openDuration", type="Number", format="Time", inherit="no")]
+
+/**
+ * An easing function to control the open transition. Easing functions can
+ * be used to control the acceleration and deceleration of the transition.
+ *
+ * @default undefined
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="openEasingFunction", type="Function", inherit="no")]
+
+/**
+ * Number of pixels between the control's bottom border
+ * and the bottom of its content area.
+ * When the <code>editable</code> property is <code>true</code>,
+ * <code>paddingTop</code> and <code>paddingBottom</code> affect the size
+ * of the ComboBox control, but do not affect the position of the editable text field.
+ *
+ * The default value for the Halo theme is 0.
+ * The default value for the Spark theme is -2.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="paddingBottom", type="Number", format="Length", inherit="no")]
+
+/**
+ * Number of pixels between the control's top border
+ * and the top of its content area.
+ * When the <code>editable</code> property is <code>true</code>,
+ * <code>paddingTop</code> and <code>paddingBottom</code> affect the size
+ * of the ComboBox control, but do not affect the position of the editable text field.
+ *
+ * The default value for the Halo theme is 0.
+ * The default value for the Spark theme is -1.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="paddingTop", type="Number", format="Length", inherit="no")]
+
+/**
+ * The rollOverColor of the drop-down list.
+ *
+ * The default value for the Halo theme is <code>0xB2E1FF</code>.
+ * The default value for the Spark theme is <code>0xCEDBEF</code>.
+ *
+ * @see mx.controls.List
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="rollOverColor", type="uint", format="Color", inherit="yes")]
+
+/**
+ * The selectionColor of the drop-down list.
+ *
+ * The default value for the Halo theme is <code>0x7FCEFF</code>.
+ * The default value for the Spark theme is <code>0xA8C6EE</code>.
+ *
+ * @see mx.controls.List
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="selectionColor", type="uint", format="Color", inherit="yes")]
+
+/**
+ * The selectionDuration of the drop-down list.
+ *
+ * @default 250
+ *
+ * @see mx.controls.List
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="selectionDuration", type="uint", format="Time", inherit="no")]
+
+/**
+ * The selectionEasingFunction of the drop-down list.
+ *
+ * @default undefined
+ *
+ * @see mx.controls.List
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="selectionEasingFunction", type="Function", inherit="no")]
+
+/**
+ * The textRollOverColor of the drop-down list.
+ *
+ * The default value for the Halo theme is <code>0x2B333C</code>.
+ * The default value for the Spark theme is <code>0x000000</code>.
+ *
+ * @see mx.controls.List
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="textRollOverColor", type="uint", format="Color", inherit="yes")]
+
+/**
+ * The textSelectedColor of the drop-down list.
+ *
+ * The default value for the Halo theme is <code>0x2B333C</code>.
+ * The default value for the Spark theme is <code>0x000000</code>.
+ *
+ * @see mx.controls.List
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+//[Style(name="textSelectedColor", type="uint", format="Color", inherit="yes")]
+
+//--------------------------------------
+// Other metadata
+//--------------------------------------
+
+[AccessibilityClass(implementation="mx.accessibility.ComboBoxAccImpl")]
+
+[DataBindingInfo("acceptedTypes", "{ dataProvider: { label: "String" } }")]
+
+[DefaultBindingProperty(source="selectedItem", destination="dataProvider")]
+
+[DefaultProperty("dataProvider")]
+
+[DefaultTriggerEvent("change")]
+
+//[IconFile("ComboBox.png")]
+
+[Alternative(replacement="spark.components.DropDownList", since="4.0")]
+[Alternative(replacement="spark.components.ComboBox", since="4.0")]
+
+/**
+ * The ComboBox control contains a drop-down list
+ * from which the user can select a single value.
+ * Its functionality is very similar to that of the
+ * SELECT form element in HTML.
+ * The ComboBox can be editable, in which case
+ * the user can type entries into the TextInput portion
+ * of the ComboBox that are not in the list.
+ *
+ * <p>The ComboBox control has the following default sizing
+ * characteristics:</p>
+ * <table class="innertable">
+ * <tr>
+ * <th>Characteristic</th>
+ * <th>Description</th>
+ * </tr>
+ * <tr>
+ * <td>Default size</td>
+ * <td>Wide enough to accommodate the longest entry in the
+ * drop-down list in the display area of the main
+ * control, plus the drop-down button. When the
+ * drop-down list is not visible, the default height
+ * is based on the label text size.
+ *
+ * <p>The default drop-down list height is five rows, or
+ * the number of entries in the drop-down list, whichever
+ * is smaller. The default height of each entry in the
+ * drop-down list is 22 pixels.</p></td>
+ * </tr>
+ * <tr>
+ * <td>Minimum size</td>
+ * <td>0 pixels.</td>
+ * </tr>
+ * <tr>
+ * <td>Maximum size</td>
+ * <td>5000 by 5000.</td>
+ * </tr>
+ * <tr>
+ * <td>dropdownWidth</td>
+ * <td>The width of the ComboBox control.</td>
+ * </tr>
+ * <tr>
+ * <td>rowCount</td>
+ * <td>5 rows.</td>
+ * </tr>
+ * </table>
+ *
+ * @mxml
+ *
+ * <p>The <code><mx:ComboBox></code> tag inherits all the tag attributes
+ * of its superclass, and adds the following tag attributes:</p>
+ *
+ * <pre>
+ * <mx:ComboBox
+ * <b>Properties</b>
+ * dataProvider="null"
+ * dropdownFactory="<i>ClassFactory that creates an mx.controls.List</i>"
+ * dropdownWidth="<i>100 or width of the longest text in the dataProvider</i>"
+ * itemRenderer="null"
+ * labelField="label"
+ * labelFunction="null"
+ * prompt="null"
+ * rowCount="5"
+ * selectedIndex="-1"
+ * selectedItem="null"
+ *
+ * <b>Styles</b>
+ * alternatingItemColors="undefined"
+ * arrowButtonWidth="22"
+ * borderColor="0xB7BABC"
+ * borderThickness="1"
+ * closeDuration="250"
+ * closeEasingFunction="undefined"
+ * color="0x0B333C"
+ * cornerRadius="0"
+ * disabledColor="0xAAB3B3"
+ * disabledIconColor="0x919999"
+ * dropdownBorderColor="undefined"
+ * dropdownStyleName="comboDropdown"
+ * fillAlphas="[0.6,0.4]"
+ * fillColors="[0xFFFFFF, 0xCCCCCC]"
+ * focusAlpha="0.4"
+ * focusRoundedCorners="tl tr bl br"
+ * fontAntiAliasType="advanced|normal"
+ * fontFamily="Verdana"
+ * fontGridFitType="pixel|none|subpixel"
+ * fontSharpness="0"
+ * fontSize="10"
+ * fontStyle="normal|italic"
+ * fontThickness="0"
+ * fontWeight="normal|bold"
+ * highlightAlphas="[0.3,0.0]"
+ * iconColor="0x111111"
+ * leading="0"
+ * openDuration="250"
+ * openEasingFunction="undefined"
+ * paddingTop="0"
+ * paddingBottom="0"
+ * paddingLeft="5"
+ * paddingRight="5"
+ * rollOverColor="<i>Depends on theme color"</i>
+ * selectionColor="<i>Depends on theme color"</i>
+ * selectionDuration="250"
+ * selectionEasingFunction="undefined"
+ * textAlign="left|center|right"
+ * textDecoration="none|underline"
+ * textIndent="0"
+ * textRollOverColor="0x2B333C"
+ * textSelectedColor="0x2B333C"
+ *
+ * <b>Events</b>
+ * change="<i>No default</i>"
+ * close="<i>No default</i>"
+ * dataChange="<i>No default</i>"
+ * enter="<i>No default</i>"
+ * itemRollOut="<i>No default</i>"
+ * itemRollOver="<i>No default</i>"
+ * open="<i>No default</i>"
+ * scroll="<i>No default</i>"
+ * />
+ * </pre>
+ *
+ * @includeExample examples/SimpleComboBox.mxml
+ *
+ * @see mx.controls.List
+ * @see mx.effects.Tween
+ * @see mx.managers.PopUpManager
+ *
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+public class ComboBox extends ComboBase
+ /*implements IDataRenderer, IDropInListItemRenderer,
+ IListItemRenderer*/
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function ComboBox()
+ {
+ super();
+
+ // It it better to start out with an empty data provider rather than
+ // an undefined one. Otherwise, code in getDropdown() sets it to []
+ // later, but via setDataProvider(). This API has side effects like
+ // setting selectionChanged, which causes the text in an editable
+ // ComboBox to be lost.
+ //dataProvider = new ArrayCollection();
+
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public var labelField:String = "label";
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+ //----------------------------------
+ // dropdown
+ //----------------------------------
+
+ /**
+ * A reference to the List control that acts as the drop-down in the ComboBox.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function get dropdown():Object // was ListBase
+ {
+ return (view as IComboBoxView).popUp;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden properties
+ //
+ //--------------------------------------------------------------------------
+
+
+ //----------------------------------
+ // selectedLabel
+ //----------------------------------
+
+ /**
+ * The String displayed in the TextInput portion of the ComboBox. It
+ * is calculated from the data by using the <code>labelField</code>
+ * or <code>labelFunction</code>.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function get selectedLabel():String
+ {
+ return itemToLabel(selectedItem);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden methods: UIComponent
+ //
+ //--------------------------------------------------------------------------
+
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns a string representing the <code>item</code> parameter.
+ *
+ * <p>This method checks in the following order to find a value to return:</p>
+ *
+ * <ol>
+ * <li>If you have specified a <code>labelFunction</code> property,
+ * returns the result of passing the item to the function.</li>
+ * <li>If the item is a String, Number, Boolean, or Function, returns
+ * the item.</li>
+ * <li>If the item has a property with the name specified by the control's
+ * <code>labelField</code> property, returns the contents of the property.</li>
+ * <li>If the item has a label property, returns its value.</li>
+ * </ol>
+ *
+ * @param item The object that contains the value to convert to a label.
+ * If the item is null, this method returns the empty string.
+ *
+ * @return A string representing the <code>item</code> parameter.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function itemToLabel(item:Object, ...rest):String
+ {
+ // rest args are needed in case dropdown is some other thing like DataGrid
+ // that has multiple arguments to labelFunction
+
+ // we need to check for null explicitly otherwise
+ // a numeric zero will not get properly converted to a string.
+ // (do not use !item)
+ if (item == null)
+ return "";
+
+ /*
+ if (labelFunction != null)
+ return labelFunction(item);
+ */
+
+ if (typeof(item) == "object")
+ {
+ try
+ {
+ if (item[labelField] != null)
+ item = item[labelField];
+ }
+ catch(e:Error)
+ {
+ }
+ }
+ else if (typeof(item) == "xml")
+ {
+ try
+ {
+ if (item[labelField].length() != 0)
+ item = item[labelField];
+ }
+ catch(e:Error)
+ {
+ }
+ }
+
+ if (typeof(item) == "string")
+ return String(item);
+
+ try
+ {
+ return item.toString();
+ }
+ catch(e:Error)
+ {
+ }
+
+ return " ";
+ }
+
+
+}
+
+}
--
To stop receiving notification emails like this one, please contact
aharui@apache.org.