flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [42/50] git commit: [flex-asjs] [refs/heads/develop] - handle autosizing better
Date Thu, 25 Sep 2014 16:04:24 GMT
handle autosizing better


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

Branch: refs/heads/develop
Commit: 1652c1461dbfd4057832ff55fb305fe3fe7aa80f
Parents: 4f9e27c
Author: Alex Harui <aharui@apache.org>
Authored: Tue Sep 23 14:38:24 2014 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Sep 23 15:04:02 2014 -0700

----------------------------------------------------------------------
 .../apache/flex/html/beads/TextFieldViewBase.as | 34 ++++++++++++++++----
 1 file changed, 27 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1652c146/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/TextFieldViewBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/TextFieldViewBase.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/TextFieldViewBase.as
index ac4fcd3..006f765 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/TextFieldViewBase.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/TextFieldViewBase.as
@@ -87,12 +87,13 @@ package org.apache.flex.html.beads
 		{
 			_strand = value;
 			_textModel = value.getBeadByType(ITextModel) as ITextModel;
-			IEventDispatcher(value).addEventListener("textChanged", textChangeHandler);
-			IEventDispatcher(value).addEventListener("htmlChanged", htmlChangeHandler);
-			IEventDispatcher(value).addEventListener("widthChanged", sizeChangeHandler);
-			IEventDispatcher(value).addEventListener("heightChanged", sizeChangeHandler);
+            _textModel.addEventListener("textChange", textChangeHandler);
+            _textModel.addEventListener("htmlChange", htmlChangeHandler);
+            _textModel.addEventListener("widthChanged", widthChangeHandler);
+            _textModel.addEventListener("heightChanged", heightChangeHandler);
 			DisplayObjectContainer(value).addChild(_textField);
-			sizeChangeHandler(null);
+            textField.width = DisplayObject(_strand).width;
+            textField.height = DisplayObject(_strand).height;
 			if (_textModel.text !== null)
 				text = _textModel.text;
 			if (_textModel.html !== null)
@@ -162,12 +163,31 @@ package org.apache.flex.html.beads
 			html = _textModel.html;
 		}
 		
-		private function sizeChangeHandler(event:Event):void
+        private var autoHeight:Boolean = true;
+        private var autoWidth:Boolean = true;
+        
+		private function widthChangeHandler(event:Event):void
 		{
+            textField.autoSize = "none";
+            autoWidth = false;
 			textField.width = DisplayObject(_strand).width;
-			textField.height = DisplayObject(_strand).height;
+            if (autoHeight)
+    			textField.height = textField.textHeight + 4;
+            else
+                textField.height = DisplayObject(_strand).height;
 		}
 
+        private function heightChangeHandler(event:Event):void
+        {
+            textField.autoSize = "none";
+            autoHeight = false;
+            textField.height = DisplayObject(_strand).height;
+            if (autoWidth)
+                textField.width = textField.textWidth + 4;
+            else
+                textField.width = DisplayObject(_strand).width;
+        }
+        
         /**
          *  @copy org.apache.flex.core.IBeadView#viewHeight
          *  


Mime
View raw message