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 178970a Adding HideComboPopupOnMouseDownBead
178970a is described below
commit 178970a4abaeba5338ada97f2d73f9a9bef31434
Author: DESKTOP-RH4S838\Yishay <[email protected]>
AuthorDate: Thu May 17 10:43:25 2018 +0300
Adding HideComboPopupOnMouseDownBead
---
.../Basic/src/main/resources/basic-manifest.xml | 1 +
.../html/beads/HideComboPopupOnMouseDownBead.as | 111 +++++++++++++++++++++
2 files changed, 112 insertions(+)
diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index dc79a5a..a4738bd 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -87,6 +87,7 @@
<component id="AccordionView"
class="org.apache.royale.html.beads.AccordionView"/>
<component id="CenterElement"
class="org.apache.royale.html.beads.CenterElement"/>
<component id="StyleInheritanceBead"
class="org.apache.royale.html.beads.StyleInheritanceBead"/>
+ <component id="HideComboPopupOnMouseDownBead"
class="org.apache.royale.html.beads.HideComboPopupOnMouseDownBead"/>
<component id="StyleInheritanceWithObserverBead"
class="org.apache.royale.html.beads.StyleInheritanceWithObserverBead"/>
<component id="CrossBrowserFireListenerOverrideBead"
class="org.apache.royale.html.beads.CrossBrowserFireListenerOverrideBead" />
<component id="AccessibilityAltBead"
class="org.apache.royale.html.beads.AccessibilityAltBead" />
diff --git
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/HideComboPopupOnMouseDownBead.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/HideComboPopupOnMouseDownBead.as
new file mode 100644
index 0000000..ba48f52
--- /dev/null
+++
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/HideComboPopupOnMouseDownBead.as
@@ -0,0 +1,111 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 org.apache.royale.html.beads
+{
+ import org.apache.royale.utils.callLater;
+ import org.apache.royale.utils.loadBeadFromValuesManager;
+ import org.apache.royale.core.IBeadController;
+ import org.apache.royale.core.IBead;
+ import org.apache.royale.core.IComboBoxModel;
+ import org.apache.royale.core.IStrand;
+ import org.apache.royale.core.IUIBase;
+ import org.apache.royale.events.Event;
+ import org.apache.royale.events.IEventDispatcher;
+ import org.apache.royale.events.MouseEvent;
+ import org.apache.royale.html.TextInput;
+ import org.apache.royale.html.List;
+ import org.apache.royale.html.beads.IComboBoxView;
+
+ /**
+ * The HideComboPopupOnMouseDownBead can be used with ComboBox to make
sure mouse down events
+ * close an open popup. For this bead to work the application needs to
be sized to the
+ * window size. See org.apache.royale.core.BrowserResizeListener for a
way to achieve this.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 9.3
+ */
+ public class HideComboPopupOnMouseDownBead implements IBead
+ {
+ public function HideComboPopupOnMouseDownBead()
+ {
+ }
+
+ private var _strand:IStrand;
+
+ protected var viewBead:IComboBoxView;
+
+ /**
+ * @copy org.apache.royale.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ * @royaleignorecoercion HTMLInputElement
+ * @royaleignorecoercion org.apache.royale.core.UIBase;
+ */
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ viewBead = _strand.getBeadByType(IComboBoxView) as
IComboBoxView;
+ if (viewBead) {
+ finishSetup(null);
+ } else {
+
IEventDispatcher(_strand).addEventListener("viewChanged", finishSetup);
+ }
+ }
+
+ protected function finishSetup(event:Event):void
+ {
+ if (viewBead == null) {
+ viewBead =
loadBeadFromValuesManager(IComboBoxView, "iBeadView", _strand) as IComboBoxView;
+ }
+
IEventDispatcher(viewBead.popUp).addEventListener("show", handlePopupShow);
+
IEventDispatcher(viewBead.popUp).addEventListener("hide", handlePopupHide);
+ }
+
+ protected function handleControlMouseDown(event:MouseEvent):void
+ {
+ event.stopImmediatePropagation();
+ }
+
+ protected function handlePopupShow(event:Event):void
+ {
+
IEventDispatcher(viewBead.popUp).addEventListener(MouseEvent.MOUSE_DOWN,
handleControlMouseDown);
+
IEventDispatcher(_strand).addEventListener(MouseEvent.MOUSE_DOWN,
handleControlMouseDown);
+ callLater(function():void {
+
IUIBase(viewBead.popUp).topMostEventDispatcher.addEventListener(MouseEvent.MOUSE_DOWN,
handleTopMostEventDispatcherMouseDown);
+ });
+ }
+
+ protected function
handleTopMostEventDispatcherMouseDown(event:MouseEvent):void
+ {
+ viewBead.popUpVisible = false;
+ }
+
+ protected function handlePopupHide(event:Event):void
+ {
+
IEventDispatcher(viewBead.popUp).removeEventListener(MouseEvent.MOUSE_DOWN,
handleControlMouseDown);
+
IEventDispatcher(_strand).removeEventListener(MouseEvent.MOUSE_DOWN,
handleControlMouseDown);
+
IUIBase(viewBead.popUp).topMostEventDispatcher.removeEventListener(MouseEvent.MOUSE_DOWN,
handleTopMostEventDispatcherMouseDown);
+ }
+ }
+}
--
To stop receiving notification emails like this one, please contact
[email protected].