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/18 19:24:47 UTC
[royale-asjs] 01/01: Bead for hiding drawer, not yet tested
This is an automated email from the ASF dual-hosted git repository.
yishayw pushed a commit to branch hide_drawer_bead
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit cfcd1adf85b68c66c3c1c0d6df1becd1ccd25202
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Sun Aug 18 22:24:10 2019 +0300
Bead for hiding drawer, not yet tested
---
.../Jewel/src/main/resources/jewel-manifest.xml | 2 +
.../beads/controls/drawer/HideDrawerOnMouseDown.as | 90 ++++++++++++++++++++++
2 files changed, 92 insertions(+)
diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index 296adc7..ead8b31 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -117,6 +117,8 @@
<component id="DrawerHeader" class="org.apache.royale.jewel.supportClasses.drawer.DrawerHeader"/>
<component id="DrawerContent" class="org.apache.royale.jewel.supportClasses.drawer.DrawerContent"/>
+ <component id="HideDrawerOnMouseDown" class="org.apache.royale.jewel.beads.controls.drawer.HideDrawerOnMouseDown"/>
+
<component id="Divider" class="org.apache.royale.jewel.Divider"/>
<component id="Image" class="org.apache.royale.jewel.Image"/>
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/drawer/HideDrawerOnMouseDown.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/drawer/HideDrawerOnMouseDown.as
new file mode 100644
index 0000000..d7ff9f9
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/drawer/HideDrawerOnMouseDown.as
@@ -0,0 +1,90 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.jewel.beads.controls.drawer
+{
+ import org.apache.royale.utils.callLater;
+ import org.apache.royale.core.IBead;
+ 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.jewel.Drawer;
+
+ /**
+ * The HideDrawerOnMouseDown can be used with a Drawer to make sure mouse down events
+ * close an open drawer. 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 0.9.6
+ */
+ public class HideDrawerOnMouseDown implements IBead
+ {
+ public function HideDrawerOnMouseDown()
+ {
+ }
+
+ private var _strand:IStrand;
+
+ /**
+ * @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;
+ IEventDispatcher(value).addEventListener("openDrawer", handlePopupShow);
+ IEventDispatcher(value).addEventListener("closeDrawer", handlePopupHide);
+ }
+
+ protected function handleControlMouseDown(event:MouseEvent):void
+ {
+ event.stopImmediatePropagation();
+ }
+
+ protected function handlePopupShow(event:Event):void
+ {
+ IEventDispatcher(event.target).addEventListener(MouseEvent.MOUSE_DOWN, handleControlMouseDown);
+ callLater(function():void {
+ IUIBase(event.target).topMostEventDispatcher.addEventListener(MouseEvent.MOUSE_DOWN, handleTopMostEventDispatcherMouseDown);
+ });
+ }
+
+ protected function handleTopMostEventDispatcherMouseDown(event:MouseEvent):void
+ {
+ (_strand as Drawer).close();
+ }
+
+ protected function handlePopupHide(event:Event):void
+ {
+ IEventDispatcher(event.target).removeEventListener(MouseEvent.MOUSE_DOWN, handleControlMouseDown);
+ IUIBase(event.target).topMostEventDispatcher.removeEventListener(MouseEvent.MOUSE_DOWN, handleTopMostEventDispatcherMouseDown);
+ }
+ }
+}
+