You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by yi...@apache.org on 2019/08/14 11:58:34 UTC
[royale-asjs] branch develop updated: Make sure controller has
state selected state ready before any external click event handlers are
triggered.
This is an automated email from the ASF dual-hosted git repository.
yishayw pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 78c60c4 Make sure controller has state selected state ready before any external click event handlers are triggered.
new b7f56c7 Merge branch 'develop' of https://github.com/apache/royale-asjs into develop
78c60c4 is described below
commit 78c60c456d488bd6475325a29403f23c3e6d830d
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Wed Aug 14 14:56:47 2019 +0300
Make sure controller has state selected state ready before any external
click event handlers are triggered.
---
.../src/main/royale/mx/controls/RadioButton.as | 45 ++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButton.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButton.as
index 4c19e74..831e07f 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButton.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButton.as
@@ -37,6 +37,7 @@ import mx.core.IFlexModuleFactory;
*/
import mx.core.mx_internal;
import mx.events.FlexEvent;
+import mx.events.MouseEvent;
/*
import mx.core.FlexVersion;
import mx.core.IToggleButton;
@@ -225,6 +226,9 @@ public class RadioButton extends Button
private var textNode:window.Text;
COMPILE::JS
private var rbicon:RadioButtonIcon;
+
+ private var clickHandlers:Vector.<Function>;
+ private var _initialized:Boolean;
/**
* @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
@@ -251,6 +255,38 @@ public class RadioButton extends Button
return element;
}
+
+ private function deferAddClickEventHandler(handler:Function):void
+ {
+ if (!clickHandlers)
+ {
+ clickHandlers = new Vector.<Function>();
+ }
+ clickHandlers.push(handler);
+ }
+
+ // as we don't have priorities to event handlers in Royale we use an override to make sure click events
+ // don't happen before controller has had a chance to take control.
+ COMPILE::SWF
+ override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
+ {
+ if (_initialized || type != MouseEvent.CLICK)
+ {
+ return super.addEventListener(type, listener, useCapture, priority, useWeakReference);
+ }
+ deferAddClickEventHandler(listener);
+ }
+
+ COMPILE::JS
+ override public function addEventListener(type:String, handler:Function, opt_capture:Boolean = false, opt_handlerScope:Object = null):void
+ {
+ if (_initialized || type != MouseEvent.CLICK)
+ {
+ return super.addEventListener(type, handler, opt_capture, opt_handlerScope);
+ }
+ deferAddClickEventHandler(handler);
+ }
+
COMPILE::JS
override public function set id(value:String):void
@@ -434,9 +470,18 @@ public class RadioButton extends Button
override public function addedToParent():void
{
super.addedToParent();
+ _initialized = true;
+ addClickEventHandlers();
commitProperties();
}
+ private function addClickEventHandlers():void
+ {
+ while (clickHandlers.length > 0)
+ {
+ super.addEventListener(MouseEvent.CLICK, clickHandlers.pop());
+ }
+ }
/**
* @private
* Update properties before measurement/layout.