Repository: flex-asjs Updated Branches: refs/heads/develop 2dd4d5d2e -> b88f92e7b
added simple positioning to tool tip / make tool tip not react to mouse events Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/b88f92e7 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/b88f92e7 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/b88f92e7 Branch: refs/heads/develop Commit: b88f92e7b304759752b6adb4e0f1007ace191c09 Parents: 2dd4d5d Author: Justin Mclean <jmcl...@apache.org> Authored: Thu Jul 13 17:16:13 2017 +1000 Committer: Justin Mclean <jmcl...@apache.org> Committed: Thu Jul 13 17:16:13 2017 +1000 ---------------------------------------------------------------------- .../main/flex/org/apache/flex/html/ToolTip.as | 26 +++++-- .../apache/flex/html/accessories/ToolTipBead.as | 79 ++++++++++++++++---- 2 files changed, 84 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b88f92e7/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ToolTip.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ToolTip.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ToolTip.as index 2f29d1b..97b2d27 100644 --- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ToolTip.as +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/ToolTip.as @@ -18,11 +18,10 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.html { - import org.apache.flex.core.ITextModel; - import org.apache.flex.core.UIBase; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; + COMPILE::SWF + { + import flash.display.InteractiveObject; + } COMPILE::JS { import org.apache.flex.core.WrappedHTMLElement; @@ -60,17 +59,28 @@ package org.apache.flex.html super(); className = "ToolTip"; } - + + /** + * @private + */ + COMPILE::SWF + override public function addedToParent():void + { + super.addedToParent(); + (element as InteractiveObject).mouseEnabled = false; + } + /** * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement */ COMPILE::JS override protected function createElement():WrappedHTMLElement { - var e:WrappedHTMLElement = super.createElement(); + var element:WrappedHTMLElement = super.createElement(); positioner.style.position = 'absolute'; + positioner.style["pointer-events"] = "none"; typeNames = "ToolTip"; - return e; + return element; } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b88f92e7/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/accessories/ToolTipBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/accessories/ToolTipBead.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/accessories/ToolTipBead.as index 8e64f3a..a22283d 100644 --- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/accessories/ToolTipBead.as +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/accessories/ToolTipBead.as @@ -18,7 +18,6 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.html.accessories { - import org.apache.flex.core.IBead; import org.apache.flex.core.IPopUpHost; import org.apache.flex.core.IStrand; @@ -54,7 +53,17 @@ package org.apache.flex.html.accessories { } + public static const TOP:int = 0; + public static const BOTTOM:int = 1; + public static const LEFT:int = 2; + public static const RIGHT:int = 3; + public static const MIDDLE:int = 4; + private var _toolTip:String; + private var tt:ToolTip; + private var host:IPopUpHost; + private var _xPos:int = RIGHT; + private var _yPos:int = BOTTOM; /** * The string to use as the toolTip. @@ -73,9 +82,37 @@ package org.apache.flex.html.accessories _toolTip = value; } - private var _strand:IStrand; + /** + * Sets the tooltip y relative position to one of + * LEFT, MIDDLE or RIGHT. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.9 + */ + public function set xPos(pos:int):void + { + _xPos = pos; + } /** + * Sets the tooltip y relative position to one of + * TOP, MIDDLE or BOTTOM. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.9 + */ + public function set yPos(pos:int):void + { + _yPos = pos; + } + + private var _strand:IStrand; + + /** * @copy org.apache.flex.core.IBead#strand * * @langversion 3.0 @@ -90,13 +127,10 @@ package org.apache.flex.html.accessories IEventDispatcher(_strand).addEventListener(MouseEvent.MOUSE_OVER, rollOverHandler, false); } - private var tt:ToolTip; - private var host:IPopUpHost; - /** * @private */ - protected function rollOverHandler( event:MouseEvent ):void + protected function rollOverHandler(event:MouseEvent):void { if (!toolTip || tt) return; @@ -113,8 +147,6 @@ package org.apache.flex.html.accessories tt.x = pt.x; tt.y = pt.y; host.addElement(tt, false); // don't trigger a layout - - tt.addEventListener(MouseEvent.MOUSE_OUT, rollOutHandler, false); } /** @@ -124,8 +156,32 @@ package org.apache.flex.html.accessories protected function determinePosition(event:MouseEvent, base:Object):Point { var comp:IUIBase = _strand as IUIBase; - var pt:Point = new Point(comp.width, comp.height); + var xFactor:Number = 1; + var yFactor:Number = 1; + var pt:Point; + + if (_xPos == LEFT) { + xFactor = Number.POSITIVE_INFINITY; + } + else if (_xPos == MIDDLE) { + xFactor = 2; + } + else if (_xPos == RIGHT) { + xFactor = 1; + } + if (_yPos == TOP) { + yFactor = Number.POSITIVE_INFINITY; + } + else if (_yPos == MIDDLE) { + yFactor = 2; + } + else if (_yPos == BOTTOM) { + yFactor = 1; + } + + pt = new Point(comp.width/xFactor, comp.height/yFactor); pt = PointUtils.localToGlobal(pt, comp); + return pt; } @@ -135,10 +191,7 @@ package org.apache.flex.html.accessories private function rollOutHandler(event:MouseEvent):void { var comp:IUIBase = _strand as IUIBase; - var outside:Boolean = event.clientX > (comp.x + comp.width) || event.clientY > (comp.y + comp.height) - || event.clientX < comp.x || event.clientY < comp.y; - // check for outside otherwise tool tip itself with flash when you roll over it - if (tt && outside) { + if (tt) { host.removeElement(tt); tt = null; }