You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Tonic <an...@hotmail.fr> on 2014/11/13 21:12:54 UTC
Re: Problems with vertical alignment of Textinput on iOS
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.