Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Highlighted
New Developer
Posts: 8
Registered: ‎12-18-2010
My Device: Not Specified
Accepted Solution

How to select all text with QNX TextInput

With QNX TextInput, is there a way to select all text? Spark TextInput has selectAll() method to select all texts, but I don't see similar method in QNX TextInput. Any idea how we can select all texts with QNX TextInput. Thanks.

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: How to select all text with QNX TextInput

hey franse,

 

just so i can get a better idea, what are you trying to do with the selected text?

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
New Developer
Posts: 8
Registered: ‎12-18-2010
My Device: Not Specified

Re: How to select all text with QNX TextInput

[ Edited ]

Thanks J Rab. I want to select all the text so that when user type in any key, it will replace the whole original text with what the user just type in. I want to programmatically set focus on the textinput and select all text in it when user click some other controls (hopefully, the keyboard will automatically show up when the textinput got focus, but I don't worry about the keyboard showing up much right now since user can invoke the keyboard by him/herself if needed)

 

Thanks.

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: How to select all text with QNX TextInput

[ Edited ]

hey franse,

 

thanks for clarification! i think i can help. here is a sample code to show my explanation. In the below code when a user clicks on the LabelButton object it will set focus to your TextInput object and then select all the text in that object. The only caveat is that it will not bring up the keyboard. so far we are no successfuly in invoking hte keyboard without the user actually clicking on the TextInput. Anyways in the below code we utilize the TextInput object's textField property as a reference to its inner TextField object. from there we use the setSelection() method to select the text inside the object from the start pos to the ending position. here is the same code:

 

 

package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.FocusEvent;
	import flash.events.MouseEvent;
	
	import qnx.ui.buttons.LabelButton;
	import qnx.ui.text.TextInput;
	
	[SWF(width="1024",height="600",backgroundColor="#CCCCCC",frameRate="30")]
	public class TextInputTest extends Sprite
	{

		private var myInput:TextInput;
		
		public function TextInputTest()
		{
			super();
			
			// support autoOrients
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			myInput = new TextInput();
			myInput.setSize(300,50);
			
			addChild(myInput);			
			
			
			var newBtn:LabelButton = new LabelButton();
			newBtn.label = "Click Me";
			newBtn.setPosition(325, 0);
			
			newBtn.addEventListener(MouseEvent.CLICK, selectMyText);
			
			addChild(newBtn);
			
		}
		private function selectMyText(e:MouseEvent):void
		{
			stage.focus = myInput;
			myInput.textField.setSelection(0, myInput.textField.length);
		}
	}
}

 

hope thats what you want. good luck!

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman