actionscript 3 - unable to place textinput at the end of the text (i.e at end of last word of text) in flex -
the requirement need textinput beside text(multiline text). did , have taken width of text , adjusted x , y position of textinput, placed beside text
ex: sample text aaaaa <textinput>
. if text in multiple lines, textinput should placed @ end of text, not beside text.
ex: sample textaaaaaaaaaaaaa aaaa bbb <textinput>
but output getting below
sample textaaaaaaaaaaaaa <textinput> aaaa bbb
do have suggestion.
below code memosteplabelbox.as
package { import mx.controls.label; import mx.controls.text; import mx.controls.textinput; import mx.core.container; public class memosteplabelbox extends container { public function memosteplabelbox() { super(); } public var textlabel:text; public var input:textinput; override protected function createchildren():void { super.createchildren(); addchild(textlabel); if (spacer) { addchild(spacer); } if (input) { addchild(input); } } override protected function updatedisplaylist(unscaledwidth:number, unscaledheight:number):void { super.updatedisplaylist(unscaledwidth, unscaledheight); var labelwidth:number = textlabel.getexplicitormeasuredwidth(); var requiredwidth:number = labelwidth; if (input) { input.setactualsize(input.getexplicitormeasuredwidth(), input.getexplicitormeasuredheight()); requiredwidth += input.width; } if (unscaledwidth) { textlabel.setactualsize(labelwidth, textlabel.getexplicitormeasuredheight()); textlabel.move(0, (unscaledheight - textlabel.height) / 2); currentx = textlabel.x + textlabel.width; if (input) { input.move(currentx, (unscaledheight - input.height) / 2); currentx = input.x + input.width; } } } } }
main.mxml
<?xml version="1.0"?> <mx:application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*" creationcomplete="stack.selectedindex = 0;"> <mx:button label="insert steps" width="100" click="oninsertstepsclick()"/>--> <local:memosteplabelbox id="hbxhasinput" width="100%"> <local:textlabel> <mx:text id="txtstep" width="100%" text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaa" /> </local:textlabel> <local:spacer> <mx:spacer id="hasinputspacer" width="6" themecolor="green" /> </local:spacer> <local:input> <mx:textinput id="txtin" width="100" paddingtop="0" paddingbottom="0" /> </local:input> </local:memosteplabelbox> </mx:application>
Comments
Post a Comment