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 c15433fe48 Add bead to signal for tooltip on overflow needed event.
c15433fe48 is described below

commit c15433fe48df5d04dbb62f5b84b555e7b0d332c8
Author: Yishay Weiss <[email protected]>
AuthorDate: Tue May 31 09:07:21 2022 +0300

    Add bead to signal for tooltip on overflow needed event.
    
    This is JS only as flash's default behavior seems sufficient.
---
 .../projects/Basic/src/main/royale/BasicClasses.as |  1 +
 .../royale/html/beads/OverflowTooltipNeeded.as     | 73 ++++++++++++++++++++++
 2 files changed, 74 insertions(+)

diff --git a/frameworks/projects/Basic/src/main/royale/BasicClasses.as 
b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
index d55dd8dc63..e36b48353b 100644
--- a/frameworks/projects/Basic/src/main/royale/BasicClasses.as
+++ b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
@@ -358,6 +358,7 @@ internal class BasicClasses
        COMPILE::JS
        {
                import org.apache.royale.html.util.DialogPolyfill; 
DialogPolyfill;
+               import org.apache.royale.html.beads.OverflowTooltipNeeded; 
OverflowTooltipNeeded;
        }
 }
 
diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/OverflowTooltipNeeded.as
 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/OverflowTooltipNeeded.as
new file mode 100644
index 0000000000..45d1b0224f
--- /dev/null
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/OverflowTooltipNeeded.as
@@ -0,0 +1,73 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.core.IBead;
+       import org.apache.royale.core.IStrand;
+       import org.apache.royale.core.IUIBase;
+       import org.apache.royale.events.MouseEvent;
+       import org.apache.royale.events.ValueEvent;
+       import org.apache.royale.events.IEventDispatcher;
+       import org.apache.royale.core.WrappedHTMLElement;
+
+       /**
+        *  The OverflowTooltipNeeded class is a bead that can be used 
+        *  to trigger an event when there's an overflow and a tooltip is needed
+        *
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.9.10
+        */
+       COMPILE::JS
+       public class OverflowTooltipNeeded implements IBead
+       {
+               public static const TOOL_TIP_NEEDED:String = "toolTipNeeded";
+
+               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.9.10
+                *  @royaleignorecoercion org.apache.royale.core.IUIBase
+                */
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       (value as 
IEventDispatcher).addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler)
+               }
+
+               /**
+                * Private
+                */
+               private function mouseOverHandler(event:MouseEvent):void
+               {
+
+                       var element:WrappedHTMLElement = (_strand as 
IUIBase).element;
+                       var style:CSSStyleDeclaration = element.style;
+                       var tooltipNeeded:Boolean = style.textOverflow == 
"ellipsis" && element.offsetWidth < element.scrollWidth;
+                       (_strand as IEventDispatcher).dispatchEvent(new 
ValueEvent(TOOL_TIP_NEEDED, tooltipNeeded));
+               }
+       }
+}
\ No newline at end of file

Reply via email to