This is an automated email from the ASF dual-hosted git repository.

aharui 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 d756e3f  first attempt at menus that don't end up off-screen.  Should 
fix #716
d756e3f is described below

commit d756e3f6aea03d4f7c26a0d9cb7e5ba0bd34af10
Author: Alex Harui <aha...@apache.org>
AuthorDate: Fri Feb 14 22:23:23 2020 -0800

    first attempt at menus that don't end up off-screen.  Should fix #716
---
 .../projects/Basic/src/main/resources/defaults.css |  1 +
 .../projects/Basic/src/main/royale/BasicClasses.as |  1 +
 .../royale/html/CascadingMenuWithOnScreenCheck.as  | 51 ++++++++++++++++++++++
 .../CascadingMenuSelectionMouseController.as       |  4 +-
 .../MXRoyale/src/main/resources/defaults.css       |  1 +
 5 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/Basic/src/main/resources/defaults.css 
b/frameworks/projects/Basic/src/main/resources/defaults.css
index 02804fb..9fbec68 100644
--- a/frameworks/projects/Basic/src/main/resources/defaults.css
+++ b/frameworks/projects/Basic/src/main/resources/defaults.css
@@ -474,6 +474,7 @@ CascadingMenu {
        IBeadModel: 
ClassReference("org.apache.royale.html.beads.models.CascadingMenuModel");
        IBeadController: 
ClassReference("org.apache.royale.html.beads.controllers.CascadingMenuSelectionMouseController");
        IItemRenderer: 
ClassReference("org.apache.royale.html.supportClasses.CascadingMenuItemRenderer");
+       IMenu: ClassReference("org.apache.royale.html.CascadingMenu");
        position: absolute;
        background-color: white;
        border-width: 1px;
diff --git a/frameworks/projects/Basic/src/main/royale/BasicClasses.as 
b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
index b2275a9..d980f8c 100644
--- a/frameworks/projects/Basic/src/main/royale/BasicClasses.as
+++ b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
@@ -70,6 +70,7 @@ internal class BasicClasses
        import org.apache.royale.html.supportClasses.MenuItemRenderer; 
MenuItemRenderer;
        import org.apache.royale.html.supportClasses.CascadingMenuItemRenderer; 
CascadingMenuItemRenderer;
        import org.apache.royale.html.CascadingMenu; CascadingMenu;
+       import org.apache.royale.html.CascadingMenuWithOnScreenCheck; 
CascadingMenuWithOnScreenCheck;
        import org.apache.royale.html.beads.CascadingMenuFactory; 
CascadingMenuFactory;
        import org.apache.royale.html.beads.models.CascadingMenuModel; 
CascadingMenuModel;
        import 
org.apache.royale.html.beads.controllers.CascadingMenuSelectionMouseController; 
CascadingMenuSelectionMouseController;
diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/CascadingMenuWithOnScreenCheck.as
 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/CascadingMenuWithOnScreenCheck.as
new file mode 100644
index 0000000..e2f125f
--- /dev/null
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/CascadingMenuWithOnScreenCheck.as
@@ -0,0 +1,51 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+import org.apache.royale.core.IUIBase;
+import org.apache.royale.core.IParent;
+import org.apache.royale.utils.UIUtils;
+
+       /**
+        * The CascadingMenuWithOnScreenCheck adjusts the position to make sure 
it is on-screen.
+        *
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.9
+        */
+       public class CascadingMenuWithOnScreenCheck extends CascadingMenu
+       {
+               override public function show(component:IUIBase, 
xoffset:Number=0, yoffset:Number=0):void
+               {
+                       var host:IParent = 
UIUtils.findPopUpHost(component).popUpParent as IParent;
+                       // save the parent dimensions because when the menu is 
added it can change the
+                       // dimensions
+                       var pw:Number = (host as IUIBase).width;
+                       var ph:Number = (host as IUIBase).height;
+                       super.show(component, xoffset, yoffset);
+                       // check to see if we fit in the parent
+                       if (y + height > ph)
+                       {
+                               y = ph - height;
+                       }
+               }
+               
+       }
+}
\ No newline at end of file
diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/CascadingMenuSelectionMouseController.as
 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/CascadingMenuSelectionMouseController.as
index a5098d5..874448d 100644
--- 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/CascadingMenuSelectionMouseController.as
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/CascadingMenuSelectionMouseController.as
@@ -30,6 +30,7 @@ package org.apache.royale.html.beads.controllers
        import org.apache.royale.html.Menu;
        import org.apache.royale.core.ISelectionModel;
        import org.apache.royale.core.UIBase;
+       import org.apache.royale.core.ValuesManager;
 
        COMPILE::JS {
                import org.apache.royale.events.BrowserEvent;
@@ -95,8 +96,9 @@ package org.apache.royale.html.beads.controllers
                        var model:CascadingMenuModel = 
_strand.getBeadByType(IBeadModel) as CascadingMenuModel;
                        
                        if (getHasMenu(node, model)) {
+                               var c:Class = 
ValuesManager.valuesImpl.getValue(_strand, "iMenu");
                                var component:IUIBase = event.target as IUIBase;
-                               var menu:IMenu = new CascadingMenu();
+                               var menu:IMenu = new c() as IMenu;
                                menu.dataProvider = 
getSubMenuDataProvider(node, model);
                                menu.labelField = model.labelField;
                                menu.parentMenuBar = (_strand as 
IMenu).parentMenuBar;
diff --git a/frameworks/projects/MXRoyale/src/main/resources/defaults.css 
b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
index e6dc580..cfd625d 100644
--- a/frameworks/projects/MXRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
@@ -58,6 +58,7 @@ Basic|CascadingMenu
        IItemRenderer: 
ClassReference("mx.controls.menuClasses.CascadingMenuItemRenderer");
        IDataProviderItemRendererMapper: 
ClassReference("mx.controls.listClasses.DataItemRendererFactoryForICollectionViewData");
        IBeadController: 
ClassReference("mx.controls.beads.controllers.CascadingMenuSelectionMouseController");
+       IMenu: 
ClassReference("org.apache.royale.html.CascadingMenuWithOnScreenCheck");
 }
 
 Basic|ComboBoxList

Reply via email to