You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2013/02/09 00:26:43 UTC

svn commit: r1444284 - in /flex/asjs/branches/develop/frameworks/as/src: FlexJSUIClasses.as org/apache/flex/html/staticControls/TextInput.as org/apache/flex/html/staticControls/beads/TextInputBead.as

Author: pent
Date: Fri Feb  8 23:26:42 2013
New Revision: 1444284

URL: http://svn.apache.org/r1444284
Log:
Adding TextInput

Added:
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/TextInput.as   (with props)
    flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputBead.as   (with props)
Modified:
    flex/asjs/branches/develop/frameworks/as/src/FlexJSUIClasses.as

Modified: flex/asjs/branches/develop/frameworks/as/src/FlexJSUIClasses.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/FlexJSUIClasses.as?rev=1444284&r1=1444283&r2=1444284&view=diff
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/FlexJSUIClasses.as (original)
+++ flex/asjs/branches/develop/frameworks/as/src/FlexJSUIClasses.as Fri Feb  8 23:26:42 2013
@@ -30,6 +30,7 @@ internal class FlexJSUIClasses
 	import org.apache.flex.html.staticControls.beads.IButtonBead; IButtonBead;
 	import org.apache.flex.html.staticControls.beads.TextButtonBead; TextButtonBead;
 	import org.apache.flex.html.staticControls.beads.TextFieldBead; TextFieldBead;
+	import org.apache.flex.html.staticControls.beads.TextInputBead; TextInputBead;
 	import org.apache.flex.html.staticControls.beads.models.TextModel; TextModel;
 }
 

Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/TextInput.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/TextInput.as?rev=1444284&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/TextInput.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/TextInput.as Fri Feb  8 23:26:42 2013
@@ -0,0 +1,47 @@
+package org.apache.flex.html.staticControls
+{
+	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IInitSkin;
+	import org.apache.flex.core.ITextBead;
+	import org.apache.flex.core.ITextModel;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.core.ValuesManager;
+	
+	public class TextInput extends UIBase implements IInitSkin
+	{
+		public function TextInput()
+		{
+			super();
+		}
+		
+		public function get text():String
+		{
+			return ITextModel(model).text;
+		}
+		public function set text(value:String):void
+		{
+			ITextModel(model).text = value;
+		}
+		
+		public function get html():String
+		{
+			return ITextModel(model).html;
+		}
+		public function set html(value:String):void
+		{
+			ITextModel(model).html = value;
+		}
+		
+		override public function initModel():void
+		{
+			if (getBeadByType(ITextModel) == null)
+				addBead(new (ValuesManager.valuesImpl.getValue("ITextModel")) as IBead);
+		}
+		
+		public function initSkin():void
+		{
+			if (getBeadByType(ITextBead) == null)
+				addBead(new (ValuesManager.valuesImpl.getValue("ITextInputBead")) as IBead);			
+		}
+	}
+}
\ No newline at end of file

Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/TextInput.as
------------------------------------------------------------------------------
    svn:eol-style = native

Added: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputBead.as
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputBead.as?rev=1444284&view=auto
==============================================================================
--- flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputBead.as (added)
+++ flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputBead.as Fri Feb  8 23:26:42 2013
@@ -0,0 +1,83 @@
+package org.apache.flex.html.staticControls.beads
+{
+	import flash.display.DisplayObjectContainer;
+	import flash.events.Event;
+	import flash.text.TextField;
+	import flash.text.TextFieldType;
+	
+	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.ITextBead;
+	import org.apache.flex.core.ITextModel;
+	
+	public class TextInputBead implements IBead, ITextBead
+	{
+		public function TextInputBead()
+		{
+			_textField = new TextField();
+			_textField.selectable = true;
+			_textField.type = TextFieldType.INPUT;
+			_textField.mouseEnabled = true;
+			
+			// for debug only
+			_textField.border = true;
+			_textField.borderColor = 0xFF0000;
+		}
+		private var textModel:ITextModel;
+		
+		private var _strand:IStrand;
+		
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			textModel = value.getBeadByType(ITextModel) as ITextModel;
+			textModel.addEventListener("textChange", textChangeHandler);
+			textModel.addEventListener("htmlChange", htmlChangeHandler);
+			DisplayObjectContainer(value).addChild(_textField);
+			if (textModel.text !== null)
+				text = textModel.text;
+			if (textModel.html !== null)
+				html = textModel.html;
+			
+			// for input, listen for changes to the _textField and update
+			// the model
+			_textField.addEventListener(Event.CHANGE, inputChangeHandler);
+		}
+		
+		private function textChangeHandler(event:Event):void
+		{
+			text = textModel.text;
+		}
+		
+		private function htmlChangeHandler(event:Event):void
+		{
+			html = textModel.html;
+		}
+		
+		private function inputChangeHandler(event:Event):void
+		{
+			textModel.text = _textField.text;
+		}
+		
+		private var _textField:TextField;
+		
+		public function get text():String
+		{
+			return _textField.text;
+		}
+		public function set text(value:String):void
+		{
+			_textField.text = value;
+		}
+		
+		public function get html():String
+		{
+			return _textField.htmlText;
+		}
+		
+		public function set html(value:String):void
+		{
+			_textField.htmlText = value;
+		}
+	}
+}
\ No newline at end of file

Propchange: flex/asjs/branches/develop/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputBead.as
------------------------------------------------------------------------------
    svn:eol-style = native