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 2015/07/28 20:41:01 UTC

[35/36] git commit: [flex-asjs] [refs/heads/develop] - HTML Inputs default to 20 chars

HTML Inputs default to 20 chars


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

Branch: refs/heads/develop
Commit: acfe9b72a37e102dd3fd9171da931566b7823177
Parents: 13cd202
Author: Alex Harui <ah...@apache.org>
Authored: Tue Jul 28 11:30:36 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Jul 28 11:30:36 2015 -0700

----------------------------------------------------------------------
 frameworks/projects/HTML/as/defaults.css        |  4 ---
 .../apache/flex/html/beads/TextFieldViewBase.as | 14 ++++----
 .../org/apache/flex/html/beads/TextInputView.as | 37 +++++++++++++++-----
 3 files changed, 35 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/acfe9b72/frameworks/projects/HTML/as/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/defaults.css b/frameworks/projects/HTML/as/defaults.css
index 062e2af..c0a8380 100644
--- a/frameworks/projects/HTML/as/defaults.css
+++ b/frameworks/projects/HTML/as/defaults.css
@@ -451,8 +451,6 @@ TextArea
     border-color: #000000;
     border-width: 1px;
     background-color: #FFFFFF;
-    width: 135;
-    height: 20;
 }
 
 TextButton
@@ -479,8 +477,6 @@ TextInput
     border-color: #000000;
     border-width: 1px;
     background-color: #FFFFFF;
-	width: 135;
-	height: 20;
 }
 
 TitleBar

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/acfe9b72/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/TextFieldViewBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/TextFieldViewBase.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/TextFieldViewBase.as
index 0bcae7f..f2214e2 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/TextFieldViewBase.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/TextFieldViewBase.as
@@ -102,7 +102,6 @@ package org.apache.flex.html.beads
 				html = _textModel.html;
             
             var ilc:ILayoutChild = host as ILayoutChild;
-            
             autoHeight = ilc.isHeightSizedToContent();
             autoWidth = ilc.isWidthSizedToContent();
             if (!autoWidth && !isNaN(ilc.explicitWidth))
@@ -268,11 +267,11 @@ package org.apache.flex.html.beads
             {
                 textField.autoSize = "none";
                 autoWidth = false;
-    			textField.width = DisplayObject(_strand).width;
+    			textField.width = host.width;
                 if (autoHeight)
         	        autoSizeIfNeeded()
                 else
-                    textField.height = DisplayObject(_strand).height;
+                    textField.height = host.height;
             }
 		}
 
@@ -282,30 +281,29 @@ package org.apache.flex.html.beads
             {
                 textField.autoSize = "none";
                 autoHeight = false;
-                textField.height = DisplayObject(_strand).height;
+                textField.height = host.height;
                 if (autoWidth)
                     autoSizeIfNeeded();
                 else
-                    textField.width = DisplayObject(_strand).width;
+                    textField.width = host.width;
             }
         }
         
         private function sizeChangeHandler(event:Event):void
         {
             var ilc:ILayoutChild = host as ILayoutChild;
-
             autoHeight = ilc.isHeightSizedToContent();
             if (!autoHeight)
             {
                 textField.autoSize = "none";
-                textField.height = DisplayObject(_strand).height;
+                textField.height = host.height;
             }
             
             autoWidth = ilc.isWidthSizedToContent();
             if (!autoWidth)
             {
                 textField.autoSize = "none";
-                textField.width = DisplayObject(_strand).width;
+                textField.width = host.width;
             }
         }
         

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/acfe9b72/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/TextInputView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/TextInputView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/TextInputView.as
index 94bf426..63c1150 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/TextInputView.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/TextInputView.as
@@ -20,7 +20,8 @@ package org.apache.flex.html.beads
 	import flash.display.DisplayObject;
 	import flash.text.TextFieldType;
 	
-	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.ILayoutChild;
+    import org.apache.flex.core.IStrand;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
 	
@@ -65,11 +66,31 @@ package org.apache.flex.html.beads
 		{
 			super.strand = value;
 			
-			// Default size
-			var ww:Number = DisplayObject(host).width;
-			if( isNaN(ww) || ww == 0 ) DisplayObject(host).width = 100;
-			var hh:Number = DisplayObject(host).height;
-			if( isNaN(hh) || hh == 0 ) DisplayObject(host).height = 18;
+            var w:Number;
+            var h:Number;
+            var ilc:ILayoutChild = host as ILayoutChild;
+            
+            if (ilc.isWidthSizedToContent())
+            {
+                // use default width of 20
+                var s:String = textField.text;
+                textField.text = "0";
+                w = textField.textWidth * 20;
+                h = textField.textHeight + 4;
+                textField.text = s;
+                ilc.setWidth(w, true);
+            }
+            if (ilc.isHeightSizedToContent())
+            {
+                if (isNaN(h))
+                {
+                    s = textField.text;
+                    textField.text = "0";
+                    h = textField.textHeight + 4;
+                    textField.text = s;                    
+                }
+                ilc.setHeight(h, true);
+            }
 			
 			IEventDispatcher(host).addEventListener("widthChanged", sizeChangedHandler);
 			IEventDispatcher(host).addEventListener("heightChanged", sizeChangedHandler);
@@ -78,10 +99,10 @@ package org.apache.flex.html.beads
 		
 		private function sizeChangedHandler(event:Event):void
 		{
-			var ww:Number = DisplayObject(host).width;
+			var ww:Number = host.width;
 			if( !isNaN(ww) && ww > 0 ) textField.width = ww;
 			
-			var hh:Number = DisplayObject(host).height;
+			var hh:Number = host.height;
 			if( !isNaN(hh) && hh > 0 ) 
             {
                 textField.height = textField.textHeight + 5;