You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by pe...@apache.org on 2018/03/14 14:11:18 UTC
[royale-asjs] branch feature/MXRoyale updated: Cleaned up Button
code. Added Image style to defaults.css.
This is an automated email from the ASF dual-hosted git repository.
pent pushed a commit to branch feature/MXRoyale
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/feature/MXRoyale by this push:
new ca4c325 Cleaned up Button code. Added Image style to defaults.css.
ca4c325 is described below
commit ca4c325234da1c46b5677f022a5d7adf7263a8d6
Author: Peter Ent <pe...@apache.org>
AuthorDate: Wed Mar 14 10:11:15 2018 -0400
Cleaned up Button code. Added Image style to defaults.css.
---
.../HelloWorld/src/main/royale/HelloWorld.mxml | 1 -
.../MXRoyale/src/main/resources/defaults.css | 7 +
.../MXRoyale/src/main/royale/mx/controls/Button.as | 758 +++------------------
3 files changed, 87 insertions(+), 679 deletions(-)
diff --git a/examples/mxroyale/HelloWorld/src/main/royale/HelloWorld.mxml b/examples/mxroyale/HelloWorld/src/main/royale/HelloWorld.mxml
index fc75030..4d01ebb 100644
--- a/examples/mxroyale/HelloWorld/src/main/royale/HelloWorld.mxml
+++ b/examples/mxroyale/HelloWorld/src/main/royale/HelloWorld.mxml
@@ -27,7 +27,6 @@ limitations under the License.
<js:initialView>
<js:View>
<mx:Label text="Hello World" x="20" y="20" />
- <mx:Button label="Push Me" x="20" y="60" />
</js:View>
</js:initialView>
diff --git a/frameworks/projects/MXRoyale/src/main/resources/defaults.css b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
index 32a0e4e..3c3e1a7 100644
--- a/frameworks/projects/MXRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
@@ -36,6 +36,13 @@ Button
IBeadModel: ClassReference("org.apache.royale.html.beads.models.ImageAndTextModel");
}
+Image
+{
+ vertical-align: top;
+ IBeadModel: ClassReference("org.apache.royale.html.beads.models.ImageModel");
+ IBeadView: ClassReference("org.apache.royale.html.beads.ImageView");
+}
+
TextInput
{
border: 1px solid #808080;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as
index 576035c..cc1a71b 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as
@@ -242,7 +242,6 @@ use namespace mx_internal;
* @playerversion AIR 1.1
* @productversion Flex 3
*/
-COMPILE::JS
public class Button extends UIComponent implements IDataRenderer
{
@@ -275,7 +274,9 @@ public class Button extends UIComponent implements IDataRenderer
public function set icon(value:String):void
{
ImageAndTextModel(model).image = value;
- setInnerHTML();
+ COMPILE::JS {
+ setInnerHTML();
+ }
}
@@ -294,7 +295,9 @@ public class Button extends UIComponent implements IDataRenderer
public function set label(value:String):void
{
ImageAndTextModel(model).text = value;
- setInnerHTML();
+ COMPILE::JS {
+ setInnerHTML();
+ }
}
//----------------------------------
@@ -379,6 +382,52 @@ public class Button extends UIComponent implements IDataRenderer
dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
}
+ //-----------------------------------
+ // listData
+ //-----------------------------------
+
+ /**
+ * @private
+ * Storage for the listData property.
+ */
+ private var _listData:BaseListData;
+
+ [Bindable("dataChange")]
+ [Inspectable(environment="none")]
+
+ /**
+ * When a component is used as a drop-in item renderer or drop-in
+ * item editor, Flex initializes the <code>listData</code> property
+ * of the component with the appropriate data from the list control.
+ * The component can then use the <code>listData</code> property
+ * to initialize the <code>data</code> property
+ * of the drop-in item renderer or drop-in item editor.
+ *
+ * <p>You do not set this property in MXML or ActionScript;
+ * Flex sets it when the component is used as a drop-in item renderer
+ * or drop-in item editor.</p>
+ *
+ * @default null
+ * @see mx.controls.listClasses.IDropInListItemRenderer
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function get listData():BaseListData
+ {
+ return _listData;
+ }
+
+ /**
+ * @private
+ */
+ public function set listData(value:BaseListData):void
+ {
+ _listData = value;
+ }
+
//----------------------------------
// selected
//----------------------------------
@@ -453,13 +502,11 @@ public class Button extends UIComponent implements IDataRenderer
* @private
* Storage for toggle property.
*/
- private var _toggle:Boolean = false;
+ private var _toggle:Boolean = false; // TBD: store in model
/**
* @private
- */
- private var toggleChanged:Boolean = false;
-
+ */
[Bindable("toggleChanged")]
[Inspectable(category="General", defaultValue="false")]
@@ -490,7 +537,7 @@ public class Button extends UIComponent implements IDataRenderer
*/
public function get toggle():Boolean
{
- return _toggle;
+ return _toggle; // TBD: retrieve from model
}
/**
@@ -498,19 +545,41 @@ public class Button extends UIComponent implements IDataRenderer
*/
public function set toggle(value:Boolean):void
{
- _toggle = value;
- toggleChanged = true;
+ _toggle = value; // TBD: store in model
dispatchEvent(new Event("toggleChanged"));
}
//----------------------------------
+ // enabled
+ //----------------------------------
+
+ /**
+ * @private
+ */
+
+ [Inspectable(category="General", enumeration="true,false", defaultValue="true")]
+
+ /**
+ * @private
+ * This is called whenever the enabled state changes.
+ */
+ override public function set enabled(value:Boolean):void
+ {
+ // TBD: redirect to bead
+ if (GOOG::DEBUG)
+ trace("Button.enabled not implemented properly.");
+ }
+
+
+ //----------------------------------
// internal
//----------------------------------
/**
* @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
*/
+ COMPILE::JS
override protected function createElement():WrappedHTMLElement
{
addElementToWrapper(this,'button');
@@ -520,6 +589,7 @@ public class Button extends UIComponent implements IDataRenderer
/**
*/
+ COMPILE::JS
protected function setInnerHTML():void
{
var inner:String = '';
@@ -531,672 +601,4 @@ public class Button extends UIComponent implements IDataRenderer
};
}
-COMPILE::SWF
-public class Button extends UIComponent
- implements IDataRenderer
-{
- //--------------------------------------------------------------------------
- //
- // Class mixins
- //
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- //
- // Constructor
- //
- //--------------------------------------------------------------------------
-
- /**
- * Constructor.
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function Button()
- {
- super();
- typeNames = "Button";
- }
-
- //--------------------------------------------------------------------------
- //
- // Variables
- //
- //--------------------------------------------------------------------------
-
- /**
- * @private
- * Skins for the various states (falseUp, trueOver, etc.)
- * are created just-in-time as they are needed.
- * Each skin is a child Sprite of this Button.
- * Each skin has a name property indicating which skin it is;
- * for example, the instance of the class specified by the falseUpSkin
- * style has the name "falseUpSkin" and can be found using
- * getChildByName(). Note that there is no falseUpSkin property
- * of Button containing a reference to this skin instance.
- * This array contains references to all skins that have been created,
- * for looping over them; without this array we wouldn't know
- * which of the children are the skins.
- * New skins are created and added to this array in viewSkin().
- */
- private var skins:Array /* of Sprite */ = [];
-
- /**
- * @private
- * A reference to the current skin.
- * Set by viewSkin().
- */
-// mx_internal var currentSkin:IFlexDisplayObject;
-
- /**
- * The icons array contains references to all icons
- * that have been created. Since each icon is a child
- * Sprite of this button, we need this array to keep
- * track of which children are icons. Each icon has a
- * name property indicating which icon it is; for example,
- * the instance of the class specified by the falseUpIcon
- * style has the name "falseUpIcon" and can be found using
- * getChildByName(). Note that there is no falseUpIcon property
- * of Button containing a reference to this icon instance.
- * New icons are created and added to this array in viewIcon().
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- protected var icons:Array /* of Sprite */ = [];
-
- /**
- * @private
- * A reference to the current icon.
- * Set by viewIcon().
- */
-// mx_internal var currentIcon:IFlexDisplayObject;
-
- /**
- * @private
- * Flags that will block default data/listData behavior
- */
- private var selectedSet:Boolean;
- private var labelSet:Boolean;
-
- /**
- * @private
- * Flags used to save information about the skin and icon styles
- */
-// mx_internal var checkedDefaultSkin:Boolean = false;
-// mx_internal var defaultSkinUsesStates:Boolean = false;
-// mx_internal var checkedDefaultIcon:Boolean = false;
-// mx_internal var defaultIconUsesStates:Boolean = false;
-
- /**
- * @private
- * Skin names.
- * Allows subclasses to re-define the skin property names.
- */
-// mx_internal var skinName:String = "skin";
-// mx_internal var emphasizedSkinName:String = "emphasizedSkin";
-// mx_internal var upSkinName:String = "upSkin";
-// mx_internal var overSkinName:String = "overSkin";
-// mx_internal var downSkinName:String = "downSkin";
-// mx_internal var disabledSkinName:String = "disabledSkin";
-// mx_internal var selectedUpSkinName:String = "selectedUpSkin";
-// mx_internal var selectedOverSkinName:String = "selectedOverSkin";
-// mx_internal var selectedDownSkinName:String = "selectedDownSkin";
-// mx_internal var selectedDisabledSkinName:String = "selectedDisabledSkin";
-
- /**
- * @private
- * Icon names.
- * Allows subclasses to re-define the icon property names.
- */
-// mx_internal var iconName:String = "icon";
-// mx_internal var upIconName:String = "upIcon";
-// mx_internal var overIconName:String = "overIcon";
-// mx_internal var downIconName:String = "downIcon";
-// mx_internal var disabledIconName:String = "disabledIcon";
-// mx_internal var selectedUpIconName:String = "selectedUpIcon";
-// mx_internal var selectedOverIconName:String = "selectedOverIcon";
-// mx_internal var selectedDownIconName:String = "selectedDownIcon";
-// mx_internal var selectedDisabledIconName:String = "selectedDisabledIcon";
-
- //--------------------------------------------------------------------------
- //
- // Overridden properties
- //
- //--------------------------------------------------------------------------
-
-
- //----------------------------------
- // enabled
- //----------------------------------
-
- /**
- * @private
- */
- private var enabledChanged:Boolean = false;
-
- [Inspectable(category="General", enumeration="true,false", defaultValue="true")]
-
- /**
- * @private
- * This is called whenever the enabled state changes.
- */
- override public function set enabled(value:Boolean):void
- {
- if (super.enabled == value)
- return;
-
- super.enabled = value;
- enabledChanged = true;
-
- invalidateProperties();
- invalidateDisplayList();
- }
-
- //----------------------------------
- // toolTip
- //----------------------------------
-
- /**
- * @private
- */
- private var _toolTipBead:ToolTipBead;
-
- [Inspectable(category="General", defaultValue="null")]
-
- /**
- * @private
- */
- override public function set toolTip(value:String):void
- {
- super.toolTip = value;
-
- _toolTipBead = getBeadByType(ToolTipBead) as ToolTipBead;
- if (_toolTipBead == null) {
- _toolTipBead = new ToolTipBead();
- addBead(_toolTipBead);
- }
- _toolTipBead.toolTip = value;
- }
-
- override public function get toolTip():String
- {
- if (_toolTipBead) {
- return _toolTipBead.toolTip;
- }
- return null;
- }
-
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
-
-
- //----------------------------------
- // data
- //----------------------------------
-
- /**
- * @private
- * Storage for the data property;
- */
- private var _data:Object;
-
- [Bindable("dataChange")]
- [Inspectable(environment="none")]
-
- /**
- * The <code>data</code> property lets you pass a value
- * to the component when you use it as an item renderer or item editor.
- * You typically use data binding to bind a field of the <code>data</code>
- * property to a property of this component.
- *
- * <p>When you use the control as a drop-in item renderer or drop-in
- * item editor, Flex automatically writes the current value of the item
- * to the <code>selected</code> property of this control.</p>
- *
- * <p>You do not set this property in MXML.</p>
- *
- * @default null
- * @see mx.core.IDataRenderer
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get data():Object
- {
- return _data;
- }
-
- /**
- * @private
- */
- public function set data(value:Object):void
- {
- _data = value;
-
- dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
- }
-
-
- //----------------------------------
- // label
- //----------------------------------
-
-
- /**
- * @private
- */
- private var labelChanged:Boolean = false;
-
- [Bindable("labelChanged")]
- [Inspectable(category="General", defaultValue="")]
-
- /**
- * Text to appear on the Button control.
- *
- * <p>If the label is wider than the Button control,
- * the label is truncated and terminated by an ellipsis (...).
- * The full label displays as a tooltip
- * when the user moves the mouse over the Button control.
- * If you have also set a tooltip by using the <code>tooltip</code>
- * property, the tooltip is displayed rather than the label text.</p>
- *
- * @default ""
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get label():String
- {
- return ImageAndTextModel(model).text;
- }
-
- /**
- * @private
- */
- public function set label(value:String):void
- {
- ImageAndTextModel(model).text = value;
- }
-
- //----------------------------------
- // labelPlacement
- //----------------------------------
-
- /**
- * @private
- * Storage for labelPlacement property.
- */
- private var _labelPlacement:String = "right";//ButtonLabelPlacement.RIGHT;
-
- [Bindable("labelPlacementChanged")]
- [Inspectable(category="General", enumeration="left,right,top,bottom", defaultValue="right")]
-
- /**
- * Orientation of the label in relation to a specified icon.
- * Valid MXML values are <code>right</code>, <code>left</code>,
- * <code>bottom</code>, and <code>top</code>.
- *
- * <p>In ActionScript, you can use the following constants
- * to set this property:
- * <code>ButtonLabelPlacement.RIGHT</code>,
- * <code>ButtonLabelPlacement.LEFT</code>,
- * <code>ButtonLabelPlacement.BOTTOM</code>, and
- * <code>ButtonLabelPlacement.TOP</code>.</p>
- *
- * @default ButtonLabelPlacement.RIGHT
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get labelPlacement():String
- {
- return _labelPlacement;
- }
-
- /**
- * @private
- */
- public function set labelPlacement(value:String):void
- {
- _labelPlacement = value;
-
- invalidateSize();
- invalidateDisplayList();
-
- dispatchEvent(new Event("labelPlacementChanged"));
- }
-
- //-----------------------------------
- // listData
- //-----------------------------------
-
- /**
- * @private
- * Storage for the listData property.
- */
- private var _listData:BaseListData;
-
- [Bindable("dataChange")]
- [Inspectable(environment="none")]
-
- /**
- * When a component is used as a drop-in item renderer or drop-in
- * item editor, Flex initializes the <code>listData</code> property
- * of the component with the appropriate data from the list control.
- * The component can then use the <code>listData</code> property
- * to initialize the <code>data</code> property
- * of the drop-in item renderer or drop-in item editor.
- *
- * <p>You do not set this property in MXML or ActionScript;
- * Flex sets it when the component is used as a drop-in item renderer
- * or drop-in item editor.</p>
- *
- * @default null
- * @see mx.controls.listClasses.IDropInListItemRenderer
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get listData():BaseListData
- {
- return _listData;
- }
-
- /**
- * @private
- */
- public function set listData(value:BaseListData):void
- {
- _listData = value;
- }
-
- //----------------------------------
- // selected
- //----------------------------------
-
- /**
- * @private
- * Storage for selected property.
- */
- private var _selected:Boolean = false;
-
- [Bindable("click")]
- [Bindable("valueCommit")]
- [Inspectable(category="General", defaultValue="false")]
-
- /**
- * Indicates whether a toggle button is toggled
- * on (<code>true</code>) or off (<code>false</code>).
- * This property can be set only if the <code>toggle</code> property
- * is set to <code>true</code>.
- *
- * <p>For a CheckBox control, indicates whether the box
- * is displaying a check mark. For a RadioButton control,
- * indicates whether the control is selected.</p>
- *
- * <p>The user can change this property by clicking the control,
- * but you can also set the property programmatically.</p>
- *
- * <p>In previous versions, If the <code>toggle</code> property
- * was set to <code>true</code>, changing this property also dispatched
- * a <code>change</code> event. Starting in version 3.0, setting this
- * property programmatically only dispatches a
- * <code>valueCommit</code> event.</p>
- *
- * @default false
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get selected():Boolean
- {
- return _selected;
- }
-
- /**
- * @private
- */
- public function set selected(value:Boolean):void
- {
- selectedSet = true;
- setSelected(value, true);
- }
-
- private function setSelected(value:Boolean,
- isProgrammatic:Boolean = false):void
- {
- if (_selected != value)
- {
- _selected = value;
-
- invalidateDisplayList();
-
- if (toggle && !isProgrammatic)
- dispatchEvent(new Event(Event.CHANGE));
-
- dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
- }
- }
-
- //----------------------------------
- // selectedField
- //----------------------------------
-
- /**
- * The name of the field in the <code>data</code> property which specifies
- * the value of the Button control's <code>selected</code> property.
- * You can set this property when you use the Button control in an item renderer.
- * The default value is null, which means that the Button control does
- * not set its selected state based on a property in the <code>data</code> property.
- *
- * @default null
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- private var _selectedField:String = null;
-
- public function get selectedField():String
- {
- return _selectedField;
- }
-
- public function set selectedField(value:String):void
- {
- _selectedField = value;
- }
-
-
- //----------------------------------
- // toggle
- //----------------------------------
-
- /**
- * @private
- * Storage for toggle property.
- */
- private var _toggle:Boolean = false;
-
- /**
- * @private
- */
- private var toggleChanged:Boolean = false;
-
- [Bindable("toggleChanged")]
- [Inspectable(category="General", defaultValue="false")]
-
- /**
- * Controls whether a Button is in a toggle state or not.
- *
- * If <code>true</code>, clicking the button toggles it
- * between a selected and an unselected state.
- * You can get or set this state programmatically
- * by using the <code>selected</code> property.
- *
- * If <code>false</code>, the button does not stay pressed
- * after the user releases it.
- * In this case, its <code>selected</code> property
- * is always <code>false</code>.
- * Buttons like this are used for performing actions.
- *
- * When <code>toggle</code> is set to <code>false</code>,
- * <code>selected</code> is forced to <code>false</code>
- * because only toggle buttons can be selected.
- *
- * @default false
- *
- * @langversion 3.0
- * @playerversion Flash 9
- * @playerversion AIR 1.1
- * @productversion Flex 3
- */
- public function get toggle():Boolean
- {
- return _toggle;
- }
-
- /**
- * @private
- */
- public function set toggle(value:Boolean):void
- {
- _toggle = value;
- toggleChanged = true;
-
- invalidateProperties();
- invalidateDisplayList();
-
- dispatchEvent(new Event("toggleChanged"));
- }
-
- //--------------------------------------------------------------------------
- //
- // Overridden methods: UIComponent
- //
- //--------------------------------------------------------------------------
-
-
- /**
- * @private
- */
- override protected function commitProperties():void
- {
- super.commitProperties();
- }
-
- /**
- * @private
- */
- override protected function measure():void
- {
- super.measure();
- }
-
- /**
- * @private
- */
- override protected function updateDisplayList(unscaledWidth:Number,
- unscaledHeight:Number):void
- {
- super.updateDisplayList(unscaledWidth, unscaledHeight);
- }
-
- //--------------------------------------------------------------------------
- //
- // Methods
- //
- //--------------------------------------------------------------------------
-
-
- /**
- * @private
- * Controls the layout of the icon and the label within the button.
- * The text/icon are aligned based on the textAlign style setting.
- */
-// mx_internal function layoutContents(unscaledWidth:Number,
-// unscaledHeight:Number,
-// offset:Boolean):void
-// {
-// // left this function here as a reminder. mx.controls.Button should have its own
-// // ButtonLayout bead which can place the icon and label.
-// }
-
-
- /**
- * @private
- */
-// mx_internal function buttonPressed():void
-// {
-// phase = ButtonPhase.DOWN;
-//
-// dispatchEvent(new FlexEvent(FlexEvent.BUTTON_DOWN));
-//
-// if (autoRepeat)
-// {
-// autoRepeatTimer.delay = getStyle("repeatDelay");
-// autoRepeatTimer.addEventListener(
-// TimerEvent.TIMER, autoRepeatTimer_timerDelayHandler);
-// autoRepeatTimer.start();
-// }
-// }
-
- /**
- * @private
- */
-// mx_internal function buttonReleased():void
-// {
-// // Remove the handlers that were added in mouseDownHandler().
-// systemManager.getSandboxRoot().removeEventListener(
-// MouseEvent.MOUSE_UP, systemManager_mouseUpHandler, true);
-// systemManager.getSandboxRoot().removeEventListener(
-// SandboxMouseEvent.MOUSE_UP_SOMEWHERE, stage_mouseLeaveHandler);
-//
-// if (autoRepeatTimer)
-// {
-// autoRepeatTimer.removeEventListener(
-// TimerEvent.TIMER, autoRepeatTimer_timerDelayHandler);
-// autoRepeatTimer.removeEventListener(
-// TimerEvent.TIMER, autoRepeatTimer_timerHandler);
-// autoRepeatTimer.reset();
-// }
-// }
-
-
- //--------------------------------------------------------------------------
- //
- // Overridden event handlers: UIComponent
- //
- //--------------------------------------------------------------------------
-
-
- //--------------------------------------------------------------------------
- //
- // Event handlers
- //
- //--------------------------------------------------------------------------
-
-
-}
-
}
--
To stop receiving notification emails like this one, please contact
pent@apache.org.