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 581a5d7017 Add tooltip on truncation to mx Label.
581a5d7017 is described below

commit 581a5d70176f371c02488c42d0d26e5eefd7bc3b
Author: Yishay Weiss <[email protected]>
AuthorDate: Tue May 31 09:41:25 2022 +0300

    Add tooltip on truncation to mx Label.
---
 .../projects/MXRoyale/src/main/royale/mx/controls/Label.as   | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Label.as 
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Label.as
index 92098b597a..7ea5835277 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Label.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Label.as
@@ -37,6 +37,7 @@ import mx.core.UIComponent;
 import mx.events.FlexEvent;
 import mx.core.IUITextField;
 import org.apache.royale.html.beads.ReversibleEllipsisOverflow;
+import org.apache.royale.html.beads.OverflowTooltipNeeded;
 
 /*
 import mx.core.UITextField;
@@ -53,6 +54,7 @@ COMPILE::JS
 import org.apache.royale.core.ITextModel;
 import org.apache.royale.events.Event;
 import org.apache.royale.binding.ItemRendererDataBinding;
+import org.apache.royale.events.ValueEvent;
 
 //--------------------------------------
 //  Events
@@ -918,6 +920,11 @@ public class Label extends UIComponent
         {
             _truncationBead = new ReversibleEllipsisOverflow();
             addBead(_truncationBead);
+            if (!toolTip) // if no tooltip is given we will need to detect 
truncation and display one
+            {
+                addBead(new OverflowTooltipNeeded());
+            }
+            addEventListener(OverflowTooltipNeeded.TOOL_TIP_NEEDED, 
tooltipNeededListener);
         } else if (_truncationBead && _truncateToFit && !value)
         {
             _truncationBead.revert();
@@ -927,6 +934,11 @@ public class Label extends UIComponent
         }
         _truncateToFit = value;
     }
+    
+    private function tooltipNeededListener(event:ValueEvent):void
+    {
+        toolTip = event.value ? text : "";
+    }
 
 
 

Reply via email to