You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2017/06/17 05:08:12 UTC
[1/8] git commit: [flex-asjs] [refs/heads/tlf] - tune up textline so
you can click and place the ibeam
Repository: flex-asjs
Updated Branches:
refs/heads/tlf 3ceecca9d -> ef940e3f4
tune up textline so you can click and place the ibeam
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/12b476c9
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/12b476c9
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/12b476c9
Branch: refs/heads/tlf
Commit: 12b476c90472acd18572a6beedf7ce42df6c4b5b
Parents: 3ceecca
Author: Alex Harui <ah...@apache.org>
Authored: Wed Jun 14 20:52:39 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jun 16 22:08:43 2017 -0700
----------------------------------------------------------------------
.../flex/org/apache/flex/text/html/TextLine.as | 71 +++++++++++++++-----
1 file changed, 55 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/12b476c9/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
index 40135d6..ba74a85 100644
--- a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
+++ b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
@@ -28,6 +28,8 @@ package org.apache.flex.text.html
COMPILE::JS
{
import org.apache.flex.core.WrappedHTMLElement;
+ import org.apache.flex.geom.Point;
+ import org.apache.flex.utils.PointUtils;
}
import org.apache.flex.text.engine.ElementFormat;
@@ -328,6 +330,10 @@ package org.apache.flex.text.html
return new Rectangle(element.offsetLeft, element.offsetTop, element.offsetWidth, element.offsetHeight);
}
+ /**
+ * @flexjsignorecoercion HTMLCanvasElement
+ * @flexjsignorecoercion CanvasRenderingContext2D
+ */
public function getAtomBounds(atomIndex:int):Rectangle
{
COMPILE::SWF
@@ -360,11 +366,16 @@ package org.apache.flex.text.html
else
{
var s:String = element.firstChild.textContent;
- (element.firstChild as HTMLElement).innerHTML = s.substring(0, atomIndex);
- w = (element.firstChild as HTMLElement).getClientRects()[0].width;
- (element.firstChild as HTMLElement).innerHTML = s;
- // fake an answer
- return new Rectangle(w, 1.2 - _textBlock.content.elementFormat.fontSize, 3, 1.2);
+ var canvas:HTMLCanvasElement = document.createElement("canvas") as HTMLCanvasElement;
+ canvas.style.height = "100%";
+ canvas.style.width = "100%";
+ element.appendChild(canvas);
+ var ctx:CanvasRenderingContext2D = canvas.getContext("2d") as CanvasRenderingContext2D;
+
+ var w1:Number = (atomIndex == 0) ? 0 : ctx.measureText(s.substring(0, atomIndex - 1)).width;
+ w = ctx.measureText(s.substring(0, atomIndex)).width;
+ element.removeChild(canvas);
+ return new Rectangle(w1, 1.2 - _textBlock.content.elementFormat.fontSize, w - w1, 1.2);
}
}
}
@@ -395,24 +406,44 @@ package org.apache.flex.text.html
}
COMPILE::JS
{
- trace("getAtomIndexAtPoint not implemented");
- //TODO atom locations. This one will be fun...
+ var pt:Point = new Point(stageX, stageY);
+ pt = PointUtils.globalToLocal(pt, this);
+ var s:String = element.firstChild.textContent;
+ if (s === "") return 0;
+ // pick a starting point for which atom it might be.
+ // assume fixed width fonts
+ var start:int = Math.floor(s.length * pt.x / width);
+ var done:Boolean = false;
+ while (!done)
+ {
+ var r:Rectangle = getAtomBounds(start);
+ if (r.left > pt.x)
+ {
+ start--;
+ if (start == 0)
+ return 0;
+ }
+ else if (r.right < pt.x)
+ {
+ start++;
+ if (start >= s.length - 1)
+ return s.length - 1;
+ }
+ else
+ return start;
+ }
return 0;
}
}
public function getAtomTextBlockBeginIndex(atomIndex:int):int
{
- trace("getAtomTextBlockBeginIndex not implemented");
- //TODO track indexes...
- return 0;
+ return _beginIndex + atomIndex;
}
public function getAtomTextBlockEndIndex(atomIndex:int):int
{
- trace("getAtomTextBlockEndIndex not implemented");
- //TODO track indexes...
- return 0;
+ return _beginIndex + atomIndex + 1;
}
public function getAtomTextRotation(atomIndex:int):String
@@ -424,9 +455,17 @@ package org.apache.flex.text.html
public function getAtomWordBoundaryOnLeft(atomIndex:int):Boolean
{
- trace("getAtomWordBoundaryOnLeft not implemented");
- //TODO we need to track word boundaries
- return false;
+ var s:String;
+ COMPILE::SWF
+ {
+ s = textField.text;
+ }
+ COMPILE::JS
+ {
+ s = element.firstChild.textContent;
+ }
+ s = s.substring(0, atomIndex);
+ return s.indexOf(" ") != -1;
}
public function getBaselinePosition(baseline:String):Number
[7/8] git commit: [flex-asjs] [refs/heads/tlf] - implement
containerRoot
Posted by ah...@apache.org.
implement containerRoot
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/54a9fea2
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/54a9fea2
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/54a9fea2
Branch: refs/heads/tlf
Commit: 54a9fea2f879e8a74399f1f33434b156ec6b2d20
Parents: 8268248
Author: Alex Harui <ah...@apache.org>
Authored: Fri Jun 16 20:56:05 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jun 16 22:08:44 2017 -0700
----------------------------------------------------------------------
.../textLayout/container/ContainerController.as | 85 ++++++++------------
1 file changed, 34 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/54a9fea2/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as
index 8baca14..047d497 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as
@@ -215,7 +215,7 @@ package org.apache.flex.textLayout.container
private var _shapeChildren:Array;
- private var _containerRoot:IParentIUIBase;
+ private var _containerRoot:IEventDispatcher;
/* Controller have a non-zero default width and height so that if you construct a text example with a container and don't
* specify width and height you will still see some text so that you can then have a clue what to do to correct its appearance.
@@ -279,29 +279,16 @@ package org.apache.flex.textLayout.container
return _rootElement ? _rootElement.computedFormat.blockProgression : BlockProgression.TB;
}
-//TODO we probably need platform specific methods to attach events to the root
/** @private Determine containerRoot in case the stage is not accessible. Normally the root is the stage. */
-// public function getContainerRoot():DisplayObject
-// {
-// // safe to test for stage existence
-// if (_containerRoot == null && _container && _container.stage)
-// {
-// // if the stage is accessible lets use it.
-// // trace("BEFORE COMPUTING CONTAINERROOT");
-// try
-// {
-// var x:int = _container.stage.numChildren;
-// _containerRoot = _container.stage;
-// }
-// catch(e:Error)
-// {
-// // TODO: some way to find the highest level accessible root???
-// _containerRoot = _container.root;
-// }
-// // trace("AFTER COMPUTING CONTAINERROOT");
-// }
-// return _containerRoot;
-// }
+ public function getContainerRoot():IEventDispatcher
+ {
+ // safe to test for stage existence
+ if (_containerRoot == null && _container) // && _container.stage)
+ {
+ _containerRoot = _container.topMostEventDispatcher;
+ }
+ return _containerRoot;
+ }
/**
* Returns the flow composer object that composes and highlights text into the container that this
@@ -1810,11 +1797,10 @@ package org.apache.flex.textLayout.container
_scrollTimer.stop();
_scrollTimer.removeEventListener(Timer.TIMER, scrollTimerHandler);
-//TODO fix this for FlexJS
-// if(!containerRoot)
-// {
-// containerRoot = getContainerRoot();
-// }
+ if(!containerRoot)
+ {
+ containerRoot = getContainerRoot();
+ }
if(containerRoot)
{
@@ -1958,15 +1944,14 @@ package org.apache.flex.textLayout.container
// we need a timer so that the mouse doesn't have to continue moving when the mouse is outside the content area
if (scrollDirection != 0 && !_scrollTimer)
{
-//TODO deal with platform specific events
-// _scrollTimer = new Timer(textFlow.configuration.scrollDragDelay); // 35 ms is the default auto-repeat interval for ScrollBars.
-// _scrollTimer.addEventListener(Timer.TIMER, scrollTimerHandler, false, 0, true);
+ _scrollTimer = new Timer(textFlow.configuration.scrollDragDelay); // 35 ms is the default auto-repeat interval for ScrollBars.
+ _scrollTimer.addEventListener(Timer.TIMER, scrollTimerHandler); // , false, 0, true);
-// if (getContainerRoot())
-// {
-// getContainerRoot().addEventListener(MouseEvent.MOUSE_UP, scrollTimerHandler, false, 0, true);
+ if (getContainerRoot())
+ {
+ getContainerRoot().addEventListener(MouseEvent.MOUSE_UP, scrollTimerHandler); // , false, 0, true);
// beginMouseCapture(); // TELL CLIENTS WE WANT mouseUpSomewhere events
-// }
+ }
_scrollTimer.start();
}
@@ -2192,18 +2177,17 @@ package org.apache.flex.textLayout.container
{
if (!_selectListenersAttached)
{
-//TODO fix root events
-// var containerRoot:DisplayObject = getContainerRoot();
-// if (containerRoot)
-// {
-// containerRoot.addEventListener(MouseEvent.MOUSE_MOVE, rootMouseMoveHandler, false, 0, true);
-// containerRoot.addEventListener(MouseEvent.MOUSE_UP, rootMouseUpHandler, false, 0, true);
-//
+ var containerRoot:IEventDispatcher = getContainerRoot();
+ if (containerRoot)
+ {
+ containerRoot.addEventListener(MouseEvent.MOUSE_MOVE, rootMouseMoveHandler); // , false, 0, true);
+ containerRoot.addEventListener(MouseEvent.MOUSE_UP, rootMouseUpHandler); //, false, 0, true);
+
// beginMouseCapture(); // TELL CLIENTS THAT WE WANT moueUpSomewhere EVENTS
-//
-//
-// _selectListenersAttached = true;
-// }
+
+
+ _selectListenersAttached = true;
+ }
}
getInteractionHandler().mouseDownHandler(event);
}
@@ -2240,12 +2224,11 @@ package org.apache.flex.textLayout.container
{
if (_selectListenersAttached)
{
-//TODO fix root events
-// CONFIG::debug { assert(getContainerRoot() != null,"No container root"); }
-// getContainerRoot().removeEventListener(MouseEvent.MOUSE_MOVE, rootMouseMoveHandler);
-// getContainerRoot().removeEventListener(MouseEvent.MOUSE_UP, rootMouseUpHandler);
+ CONFIG::debug { assert(getContainerRoot() != null,"No container root"); }
+ getContainerRoot().removeEventListener(MouseEvent.MOUSE_MOVE, rootMouseMoveHandler);
+ getContainerRoot().removeEventListener(MouseEvent.MOUSE_UP, rootMouseUpHandler);
// endMouseCapture(); // TELL CLIENTS WE NO LONGER WANT mouseUpSomewhere EVENTS
-// _selectListenersAttached = false;
+ _selectListenersAttached = false;
}
}
[3/8] git commit: [flex-asjs] [refs/heads/tlf] - remove padding so
selection shapes line up on JS
Posted by ah...@apache.org.
remove padding so selection shapes line up on JS
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/3172982b
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/3172982b
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/3172982b
Branch: refs/heads/tlf
Commit: 3172982b21ec7616ed3fe4b6e563e3b05840ec57
Parents: 12b476c
Author: Alex Harui <ah...@apache.org>
Authored: Wed Jun 14 23:21:26 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jun 16 22:08:44 2017 -0700
----------------------------------------------------------------------
manualtests/TLFEditTestFlexJS/src/TLFEditTestFlexJS.mxml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3172982b/manualtests/TLFEditTestFlexJS/src/TLFEditTestFlexJS.mxml
----------------------------------------------------------------------
diff --git a/manualtests/TLFEditTestFlexJS/src/TLFEditTestFlexJS.mxml b/manualtests/TLFEditTestFlexJS/src/TLFEditTestFlexJS.mxml
index 1f98b72..22d468d 100644
--- a/manualtests/TLFEditTestFlexJS/src/TLFEditTestFlexJS.mxml
+++ b/manualtests/TLFEditTestFlexJS/src/TLFEditTestFlexJS.mxml
@@ -21,7 +21,7 @@
border: 1px solid #808080;
backgroundColor: #00FFFF;
border-radius: 2px;
- padding: 4px;
+ padding: 0px;
margin: 0px;
}
</fx:Style>
[2/8] git commit: [flex-asjs] [refs/heads/tlf] - replaceText should
handle null
Posted by ah...@apache.org.
replaceText should handle null
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/3b884541
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/3b884541
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/3b884541
Branch: refs/heads/tlf
Commit: 3b8845416de9c10b52066b53eace3a30f7f1bee2
Parents: 2680873
Author: Alex Harui <ah...@apache.org>
Authored: Fri Jun 16 20:59:31 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jun 16 22:08:44 2017 -0700
----------------------------------------------------------------------
.../main/flex/org/apache/flex/text/engine/TextElement.as | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3b884541/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/TextElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/TextElement.as b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/TextElement.as
index a77b40b..6d4158c 100644
--- a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/TextElement.as
+++ b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/TextElement.as
@@ -61,9 +61,14 @@ package org.apache.flex.text.engine
}
public function replaceText(beginIndex:int, endIndex:int, newText:String):void
{
- var b:String = _text.substring(0,beginIndex);
- var e:String = _text.substring(endIndex);
- _text = b + newText + e;
+ if (_text == null)
+ _text = newText;
+ else
+ {
+ var b:String = _text.substring(0,beginIndex);
+ var e:String = _text.substring(endIndex);
+ _text = b + newText + e;
+ }
resetGlyphs();
resetText();
}
[6/8] git commit: [flex-asjs] [refs/heads/tlf] - fix up
replaceElements for Flash
Posted by ah...@apache.org.
fix up replaceElements for Flash
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/26808731
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/26808731
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/26808731
Branch: refs/heads/tlf
Commit: 26808731c60e3864796f54537316456cd7b9dcc2
Parents: 54a9fea
Author: Alex Harui <ah...@apache.org>
Authored: Fri Jun 16 20:57:21 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jun 16 22:08:44 2017 -0700
----------------------------------------------------------------------
.../org/apache/flex/text/engine/GroupElement.as | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/26808731/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/GroupElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/GroupElement.as b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/GroupElement.as
index 7d6681b..a61c97f 100644
--- a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/GroupElement.as
+++ b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/engine/GroupElement.as
@@ -67,10 +67,22 @@ package org.apache.flex.text.engine
}
public function replaceElements(beginIndex:int, endIndex:int, newElements:Vector.<ContentElement>):Vector.<ContentElement>
{
- //TODO will this work correctly in Flash? -- using Array.concat with a Vector and Vector splice with an array.
- var args:Array = [beginIndex, endIndex-beginIndex].concat(newElements);
- _elements.splice.apply(_elements, args);
+ COMPILE::SWF
+ {
+ var args:Array = [beginIndex, endIndex-beginIndex];
+ // Vectors don't seen to support concat with an array/vector parameter
+ if (newElements)
+ {
+ for each (var el:ContentElement in newElements)
+ args = args.concat(el);
+ }
+ }
+ COMPILE::JS
+ {
+ var args:Array = [beginIndex, endIndex-beginIndex].concat(newElements);
// _elements.splice(beginIndex,endIndex-beginIndex);
+ }
+ _elements.splice.apply(_elements, args);
return _elements;
}
public function setElements(value:Vector.<ContentElement>):void
Re: [5/8] git commit: [flex-asjs] [refs/heads/tlf] - remove buttonDown from JS. It is supposedly unreliable on JS. Folks will have to track mouseDown and mouseUp
Posted by Harbs <ha...@gmail.com>.
I beg to differ.
Yes. The HTML one is always false for mouse move events, but I do think the Flex MouseEvent should have a buttonDown property. (Actually, it should probably have a property for info on which button is pressed.) The state tracking should be passed along with the event.
> On Jun 17, 2017, at 8:08 AM, aharui@apache.org wrote:
>
> remove buttonDown from JS. It is supposedly unreliable on JS. Folks will have to track mouseDown and mouseUp
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/1677f0a9
> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/1677f0a9
> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/1677f0a9
>
> Branch: refs/heads/tlf
> Commit: 1677f0a9a6a5474faaba5b2996178866faa69417
> Parents: 3b88454
> Author: Alex Harui <ah...@apache.org>
> Authored: Fri Jun 16 21:01:25 2017 -0700
> Committer: Alex Harui <ah...@apache.org>
> Committed: Fri Jun 16 22:08:44 2017 -0700
>
> ----------------------------------------------------------------------
> .../Core/src/main/flex/org/apache/flex/events/MouseEvent.as | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1677f0a9/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
> index 1cea36d..c2fe391 100644
> --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
> +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
> @@ -247,7 +247,6 @@ package org.apache.flex.events
> this.ctrlKey = ctrlKey;
> this.altKey = altKey;
> this.shiftKey = shiftKey;
> - this.buttonDown = buttonDown;
> this.delta = delta;
> this.commandKey = commandKey;
> this.controlKey = controlKey;
> @@ -280,7 +279,10 @@ package org.apache.flex.events
> public var ctrlKey:Boolean;
> public var altKey:Boolean;
> public var shiftKey:Boolean;
> - public var buttonDown:Boolean;
> + // MDL says buttonDown is unreliable in JS for mouseMove so hide
> + // the API so folks get compile errors and keep their own flags
> + // for mouseDown/mouseUp
> + private var buttonDown:Boolean;
> public var delta:int;
> public var commandKey:Boolean;
> public var controlKey:Boolean;
>
[5/8] git commit: [flex-asjs] [refs/heads/tlf] - remove buttonDown
from JS. It is supposedly unreliable on JS. Folks will have to track
mouseDown and mouseUp
Posted by ah...@apache.org.
remove buttonDown from JS. It is supposedly unreliable on JS. Folks will have to track mouseDown and mouseUp
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/1677f0a9
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/1677f0a9
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/1677f0a9
Branch: refs/heads/tlf
Commit: 1677f0a9a6a5474faaba5b2996178866faa69417
Parents: 3b88454
Author: Alex Harui <ah...@apache.org>
Authored: Fri Jun 16 21:01:25 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jun 16 22:08:44 2017 -0700
----------------------------------------------------------------------
.../Core/src/main/flex/org/apache/flex/events/MouseEvent.as | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1677f0a9/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
index 1cea36d..c2fe391 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/events/MouseEvent.as
@@ -247,7 +247,6 @@ package org.apache.flex.events
this.ctrlKey = ctrlKey;
this.altKey = altKey;
this.shiftKey = shiftKey;
- this.buttonDown = buttonDown;
this.delta = delta;
this.commandKey = commandKey;
this.controlKey = controlKey;
@@ -280,7 +279,10 @@ package org.apache.flex.events
public var ctrlKey:Boolean;
public var altKey:Boolean;
public var shiftKey:Boolean;
- public var buttonDown:Boolean;
+ // MDL says buttonDown is unreliable in JS for mouseMove so hide
+ // the API so folks get compile errors and keep their own flags
+ // for mouseDown/mouseUp
+ private var buttonDown:Boolean;
public var delta:int;
public var commandKey:Boolean;
public var controlKey:Boolean;
[8/8] git commit: [flex-asjs] [refs/heads/tlf] - stop using
buttonDown. Supposedly unreliable in browsers for mouseMove. Instead track
buttonDown via mouseDown and mouseUp. Probably need to capture mouseup on
other targets someday
Posted by ah...@apache.org.
stop using buttonDown. Supposedly unreliable in browsers for mouseMove. Instead track buttonDown via mouseDown and mouseUp. Probably need to capture mouseup on other targets someday
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/ef940e3f
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/ef940e3f
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/ef940e3f
Branch: refs/heads/tlf
Commit: ef940e3f414ac6b2777287ad40302dac2cd53fec
Parents: 1677f0a
Author: Alex Harui <ah...@apache.org>
Authored: Fri Jun 16 22:08:08 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jun 16 22:08:45 2017 -0700
----------------------------------------------------------------------
.../textLayout/container/ContainerController.as | 26 +++++++++++---------
.../container/TextContainerManager.as | 10 ++++++--
.../flex/textLayout/edit/SelectionManager.as | 9 ++++++-
.../flex/textLayout/elements/LinkElement.as | 8 ++++--
.../events/FlowElementMouseEventManager.as | 13 +++++++---
5 files changed, 46 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ef940e3f/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as
index 047d497..e6ed682 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/ContainerController.as
@@ -18,14 +18,6 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.textLayout.container
{
- import org.apache.flex.textLayout.elements.GlobalSettings;
- import org.apache.flex.textLayout.elements.IInlineGraphicElement;
- import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
- import org.apache.flex.textLayout.elements.ITableRowElement;
- import org.apache.flex.textLayout.utils.CreateTLFUtil;
- import org.apache.flex.textLayout.elements.ITableCellElement;
- import org.apache.flex.textLayout.elements.IParagraphElement;
- import org.apache.flex.textLayout.elements.IFlowLeafElement;
import org.apache.flex.core.IChild;
import org.apache.flex.core.IParentIUIBase;
import org.apache.flex.core.IUIBase;
@@ -47,6 +39,7 @@ package org.apache.flex.textLayout.container
import org.apache.flex.textLayout.compose.FlowDamageType;
import org.apache.flex.textLayout.compose.IFlowComposer;
import org.apache.flex.textLayout.compose.ITextFlowLine;
+ import org.apache.flex.textLayout.compose.ITextFlowTableBlock;
import org.apache.flex.textLayout.compose.TextLineRecycler;
import org.apache.flex.textLayout.debug.Debugging;
import org.apache.flex.textLayout.debug.assert;
@@ -56,11 +49,17 @@ package org.apache.flex.textLayout.container
import org.apache.flex.textLayout.edit.IInteractionEventHandler;
import org.apache.flex.textLayout.edit.ISelectionManager;
import org.apache.flex.textLayout.edit.SelectionFormat;
- import org.apache.flex.textLayout.elements.IBackgroundManager;
import org.apache.flex.textLayout.elements.CellCoordinates;
+ import org.apache.flex.textLayout.elements.GlobalSettings;
+ import org.apache.flex.textLayout.elements.IBackgroundManager;
import org.apache.flex.textLayout.elements.IContainerFormattedElement;
- import org.apache.flex.textLayout.elements.TableBlockContainer;
+ import org.apache.flex.textLayout.elements.IFlowLeafElement;
+ import org.apache.flex.textLayout.elements.IInlineGraphicElement;
+ import org.apache.flex.textLayout.elements.IParagraphElement;
+ import org.apache.flex.textLayout.elements.ITableCellElement;
+ import org.apache.flex.textLayout.elements.ITableRowElement;
import org.apache.flex.textLayout.elements.ITextFlow;
+ import org.apache.flex.textLayout.elements.TableBlockContainer;
import org.apache.flex.textLayout.events.ActivateEvent;
import org.apache.flex.textLayout.events.ContextMenuEvent;
import org.apache.flex.textLayout.events.EditEvent;
@@ -78,7 +77,7 @@ package org.apache.flex.textLayout.container
import org.apache.flex.textLayout.formats.ITextLayoutFormat;
import org.apache.flex.textLayout.formats.TextLayoutFormat;
import org.apache.flex.textLayout.formats.TextLayoutFormatBase;
-
+ import org.apache.flex.textLayout.utils.CreateTLFUtil;
import org.apache.flex.textLayout.utils.Twips;
import org.apache.flex.utils.DisplayUtils;
import org.apache.flex.utils.ObjectMap;
@@ -121,6 +120,7 @@ package org.apache.flex.textLayout.container
private var _container:IParentIUIBase;
private var _mouseEventManager:FlowElementMouseEventManager;
+ private var buttonDown:Boolean;
// note must be protected - subclass sets or gets this variable but can't be public
/** computed container attributes. @private */
@@ -2175,6 +2175,7 @@ package org.apache.flex.textLayout.container
/** @private Does required mouseDown handling. Calls mouseDownHandler. @see #mouseDownHandler */
public function requiredMouseDownHandler(event:MouseEvent):void
{
+ buttonDown = true;
if (!_selectListenersAttached)
{
var containerRoot:IEventDispatcher = getContainerRoot();
@@ -2215,6 +2216,7 @@ package org.apache.flex.textLayout.container
/** @private */
public function rootMouseUpHandler(event:MouseEvent):void
{
+ buttonDown = false;
clearSelectHandlers();
getInteractionHandler().mouseUpHandler(event);
}
@@ -2327,7 +2329,7 @@ package org.apache.flex.textLayout.container
{
//TODO fix this
// only autoscroll if we haven't hit something on the stage related to this particular TextFlow
- if (event.buttonDown && !hitOnMyFlowExceptLastContainer(event))
+ if (buttonDown && !hitOnMyFlowExceptLastContainer(event))
// autoScrollIfNecessary(event.stageX, event.stageY);
interactionManager.mouseMoveHandler(event);
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ef940e3f/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TextContainerManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TextContainerManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TextContainerManager.as
index 457dd88..77c7cb8 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TextContainerManager.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/container/TextContainerManager.as
@@ -2525,8 +2525,14 @@ class RemappedMouseEvent extends org.apache.flex.events.MouseEvent
containerPoint = new Point();
/* event.commandKey,event.controlKey,event.clickCount are also supported in AIR. IMHO they are a nonissue for the initial click */
- super(event.type,event.bubbles,event.cancelable,containerPoint.x,containerPoint.y,event.relatedObject,event.ctrlKey,event.altKey,event.shiftKey,event.buttonDown,event.delta);
-
+ COMPILE::SWF
+ {
+ super(event.type,event.bubbles,event.cancelable,containerPoint.x,containerPoint.y,event.relatedObject,event.ctrlKey,event.altKey,event.shiftKey,event.buttonDown,event.delta);
+ }
+ COMPILE::JS
+ {
+ super(event.type,event.bubbles,event.cancelable,containerPoint.x,containerPoint.y,event.relatedObject,event.ctrlKey,event.altKey,event.shiftKey,false,event.delta);
+ }
_event = event;
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ef940e3f/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as
index 5fdc97f..6a9d11c 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/edit/SelectionManager.as
@@ -1976,6 +1976,9 @@ package org.apache.flex.textLayout.edit
// ///////////////////////////////////
// Mouse and keyboard methods
// ///////////////////////////////////
+
+ private var buttonDown:Boolean;
+
/**
* @copy IInteractionEventHandler#mouseDownHandler()
*
@@ -1986,6 +1989,8 @@ package org.apache.flex.textLayout.edit
*/
public function mouseDownHandler(event:MouseEvent):void
{
+ buttonDown = true;
+
if (subManager)
subManager.selectRange(-1, -1);
@@ -2047,7 +2052,7 @@ package org.apache.flex.textLayout.edit
setMouseCursor(MouseCursor.IBEAM);
}
- if (event.buttonDown)
+ if (buttonDown)
{
var cell:ITableCellElement = _textFlow.parentElement as ITableCellElement;
@@ -2109,6 +2114,8 @@ package org.apache.flex.textLayout.edit
*/
public function mouseUpHandler(event:MouseEvent):void
{
+ buttonDown = false;
+
if (!_mouseOverSelectionArea)
{
setMouseCursor(MouseCursor.AUTO);
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ef940e3f/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkElement.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkElement.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkElement.as
index 72cc6ca..6cfdb84 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkElement.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/elements/LinkElement.as
@@ -496,12 +496,15 @@ package org.apache.flex.textLayout.elements
}
}
+ private var buttonDown:Boolean;
+
/** @private
* The ElementMouseEventManager calls this method directly. Note that the mouse
* coordinates are unrelated to any coordinate in the container or this element.
*/
public function mouseDownHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void
{
+ buttonDown = true;
mgr.setHandCursor(true);
setToState(LinkState.ACTIVE);
evt.stopImmediatePropagation();
@@ -514,7 +517,7 @@ package org.apache.flex.textLayout.elements
public function mouseMoveHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void
{
mgr.setHandCursor(true);
- setToState(evt.buttonDown ? LinkState.ACTIVE : LinkState.HOVER);
+ setToState(buttonDown ? LinkState.ACTIVE : LinkState.HOVER);
}
/** @private
@@ -534,7 +537,7 @@ package org.apache.flex.textLayout.elements
public function mouseOverHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void
{
mgr.setHandCursor(true);
- setToState(evt.buttonDown ? LinkState.ACTIVE : LinkState.HOVER);
+ setToState(buttonDown ? LinkState.ACTIVE : LinkState.HOVER);
}
/** @private
@@ -543,6 +546,7 @@ package org.apache.flex.textLayout.elements
*/
public function mouseUpHandler(mgr:FlowElementMouseEventManager, evt:MouseEvent):void
{
+ buttonDown = false;
mgr.setHandCursor(true);
setToState(LinkState.HOVER);
evt.stopImmediatePropagation();
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ef940e3f/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEventManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEventManager.as b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEventManager.as
index ffa16e5..7c53953 100644
--- a/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEventManager.as
+++ b/frameworks/projects/TLF/src/main/flex/org/apache/flex/textLayout/events/FlowElementMouseEventManager.as
@@ -28,10 +28,10 @@ package org.apache.flex.textLayout.events
import org.apache.flex.textLayout.container.IContainerController;
import org.apache.flex.textLayout.container.ScrollPolicy;
import org.apache.flex.textLayout.debug.assert;
- import org.apache.flex.textLayout.elements.IFlowGroupElement;
import org.apache.flex.textLayout.elements.IFlowElement;
- import org.apache.flex.textLayout.elements.ITextFlow;
+ import org.apache.flex.textLayout.elements.IFlowGroupElement;
import org.apache.flex.textLayout.elements.ILinkElement;
+ import org.apache.flex.textLayout.elements.ITextFlow;
import org.apache.flex.textLayout.elements.TextRange;
import org.apache.flex.textLayout.formats.BlockProgression;
import org.apache.flex.textLayout.utils.GeometryUtil;
@@ -524,6 +524,8 @@ package org.apache.flex.textLayout.events
link.mouseOutHandler(this, _lastMouseEvent);
}
+ private var buttonDown:Boolean;
+
/** @private
* Process mouse events.
*
@@ -536,6 +538,11 @@ package org.apache.flex.textLayout.events
if (!_hitTests)
return;
+ if (evt.type == MouseEvent.MOUSE_DOWN)
+ buttonDown = true;
+ else if (evt.type == MouseEvent.MOUSE_UP)
+ buttonDown = false;
+
// note that mouseOver and mouseOut are used for hit-testing only
// need the last mouse event's button state to pass in to LinkElement
// in case the state of the Ctrl key changes (see hitTestKeyEventHandler())
@@ -549,7 +556,7 @@ package org.apache.flex.textLayout.events
if (_currentElement)
// generate a mouseOut event
localDispatchEvent(FlowElementMouseEvent.ROLL_OUT, evt);
- else if (evt.buttonDown)
+ else if (buttonDown)
// do not interact if the button is down to not disturb e.g.
// a mark operation in the container
_blockInteraction = true;
[4/8] git commit: [flex-asjs] [refs/heads/tlf] - Canvas renders fonts
differently than span so have to use span to measure
Posted by ah...@apache.org.
Canvas renders fonts differently than span so have to use span to measure
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/82682482
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/82682482
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/82682482
Branch: refs/heads/tlf
Commit: 82682482e6a592e551d06dcd8ab239937614ca67
Parents: 3172982
Author: Alex Harui <ah...@apache.org>
Authored: Thu Jun 15 22:09:56 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jun 16 22:08:44 2017 -0700
----------------------------------------------------------------------
.../flex/org/apache/flex/text/html/TextLine.as | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/82682482/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
index ba74a85..1bbdf65 100644
--- a/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
+++ b/frameworks/projects/Text/src/main/flex/org/apache/flex/text/html/TextLine.as
@@ -366,15 +366,17 @@ package org.apache.flex.text.html
else
{
var s:String = element.firstChild.textContent;
- var canvas:HTMLCanvasElement = document.createElement("canvas") as HTMLCanvasElement;
- canvas.style.height = "100%";
- canvas.style.width = "100%";
- element.appendChild(canvas);
- var ctx:CanvasRenderingContext2D = canvas.getContext("2d") as CanvasRenderingContext2D;
-
- var w1:Number = (atomIndex == 0) ? 0 : ctx.measureText(s.substring(0, atomIndex - 1)).width;
- w = ctx.measureText(s.substring(0, atomIndex)).width;
- element.removeChild(canvas);
+ var span:HTMLSpanElement = document.createElement("span") as HTMLSpanElement;
+ element.appendChild(span);
+ var w1:Number = 0;
+ if (atomIndex > 0)
+ {
+ span.innerHTML = s.substring(0, atomIndex);
+ w1 = span.getClientRects()[0].width;
+ }
+ span.innerHTML = s.substring(0, atomIndex + 1);
+ w = span.getClientRects()[0].width;
+ element.removeChild(span);
return new Rectangle(w1, 1.2 - _textBlock.content.elementFormat.fontSize, w - w1, 1.2);
}
}