flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject git commit: [flex-asjs] [refs/heads/tlf] - get point cursor to move as you type
Date Tue, 09 May 2017 04:39:21 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/tlf 56a507d5e -> ff285e6c9


get point cursor to move as you type


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/ff285e6c
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/ff285e6c
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/ff285e6c

Branch: refs/heads/tlf
Commit: ff285e6c918f69792a58f6df8f71a5e809e667f2
Parents: 56a507d
Author: Alex Harui <aharui@apache.org>
Authored: Mon May 8 21:39:16 2017 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Mon May 8 21:39:16 2017 -0700

----------------------------------------------------------------------
 .../textLayout/container/ContainerController.as |  6 +++-
 .../flex/org/apache/flex/text/html/TextLine.as  | 30 +++++++++++++++++---
 2 files changed, 31 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff285e6c/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 74593c6..8baca14 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
@@ -2825,6 +2825,8 @@ package org.apache.flex.textLayout.container
 		public function drawPointSelection(selFormat:SelectionFormat, x:Number,y:Number,w:Number,h:Number):void
 		{
 //TODO create shape in abstract way
+//AJH: probably should be graphicContainer with selection rectangles drawn at offset positions
instead
+//of positioning a rectangle.
 			var selObj:IRect = textFlow.tlfFactory.getRect();
 			
 			// Oh, this is ugly. If we are in right aligned text, and there is no padding, and the
scrollRect is set, 
@@ -2845,11 +2847,13 @@ package org.apache.flex.textLayout.container
 			selObj.fill = new SolidColor(selFormat.pointColor);
 //			selObj.graphics.beginFill(selFormat.pointColor);
 			// pixel snap - works for unscaled text - scaled text will have to accept fuzzy cursors
-			selObj.drawRect(int(x),int(y),w,h);
+			selObj.drawRect(0,0,w,h);
 			selObj.width = w;
 			selObj.height = h;
 //			selObj.graphics.drawRect(int(x),int(y),w,h);
 //			selObj.graphics.endFill();
+			selObj.x = x;
+			selObj.y = y;
 			
 			// make it blink.  But we never blink unless the text is r/w
 			if (selFormat.pointBlinkRate != 0 && interactionManager.editingMode == EditingMode.READ_WRITE)

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff285e6c/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 b865f33..7c195bd 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
@@ -310,15 +310,37 @@ package org.apache.flex.text.html
 				var r:Object = textField.getCharBoundaries(atomIndex);
 				if (r == null)
 				{
-					// not sure why we get null sometimes, but fake an answer
-					return new Rectangle(0, 1.2 - Number(textField.defaultTextFormat.size), 3, 1.2);
+					// getCharBoundaries doesn't seem to work if char is paragraph terminator
+					if (textField.text.charAt(atomIndex) == "\u2029")
+					{
+						if (textField.text.length == 1)
+							return new Rectangle(0, 1.2 - Number(textField.defaultTextFormat.size), 3, 1.2);
+						else
+						{
+							r = textField.getCharBoundaries(atomIndex - 1);
+							return new Rectangle(r.right, 1.2 - Number(textField.defaultTextFormat.size), 3, 1.2)
+						}
+					}
 				}
 				return Rectangle.fromObject(r);
 			}
 			COMPILE::JS
 			{
-				// fake an answer
-				return new Rectangle(0, 1.2 - _textBlock.content.elementFormat.fontSize, 3, 1.2);
+				var w:Number;
+				if (atomIndex == element.firstChild.textContent.length - 1)
+				{
+					w = (element.firstChild as HTMLElement).getClientRects()[0].width;
+					return new Rectangle(w, 1.2 - _textBlock.content.elementFormat.fontSize, 3, 1.2);
+				}
+				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);
+				}
 			}
 		}
 


Mime
View raw message