flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tonic <anthony.man...@hotmail.fr>
Subject Re: Problems with vertical alignment of Textinput on iOS
Date Thu, 13 Nov 2014 20:12:54 GMT
It seems this problem is not resolved.

To fix this problem, I override the layoutContent function in skin
ScrollingStageTextInputSkin, and add the half of font size : 

[CODE]
override protected function layoutContents(unscaledWidth:Number, 
												   unscaledHeight:Number):void
		{
			// base class handles border position & size
			super.layoutContents(unscaledWidth, unscaledHeight);
			
			// position & size the text
			var paddingLeft:Number = getStyle("paddingLeft");
			var paddingRight:Number = getStyle("paddingRight");
			var paddingTop:Number = getStyle("paddingTop");
			var paddingBottom:Number = getStyle("paddingBottom");
			
			var unscaledTextWidth:Number = Math.max(0, unscaledWidth - paddingLeft -
paddingRight);
			var unscaledTextHeight:Number = Math.max(0, unscaledHeight - paddingTop -
paddingBottom);
			
			var fontSize : Number = getStyle('fontSize');
			if(isNaN(fontSize))
				fontSize = 0;
	
			// default vertical positioning is centered
			var textHeight:Number = getElementPreferredHeight(textDisplay);
			var textY:Number = Math.round(0.5 * (unscaledTextHeight - textHeight)) +
paddingTop - (fontSize/2);
			
			if (textDisplay)
			{
				textDisplay.commitStyles();
				setElementSize(textDisplay, unscaledTextWidth, unscaledTextHeight);
				setElementPosition(textDisplay, paddingLeft, textY);
			}
			
			if (promptDisplay)
			{
				if (promptDisplay is StyleableTextField)
					StyleableTextField(promptDisplay).commitStyles();
				
				var promptHeight:Number = getElementPreferredHeight(promptDisplay);
				var promptY:Number = Math.round(0.5 * (unscaledTextHeight -
promptHeight)) + paddingTop;
				
				setElementSize(promptDisplay, unscaledTextWidth, promptHeight);
				setElementPosition(promptDisplay, paddingLeft, promptY);
			}
		}
[/CODE]



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Problems-with-vertical-alignment-of-Textinput-on-iOS-tp7417p8742.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Mime
View raw message