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
Developer
Posts: 297
Registered: ‎10-30-2010
My Device: PlayBook
My Carrier: other
Accepted Solution

TextInput setFocus method??

I really need to auto set focus to TextInput box. How do I do it?

Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook
My Carrier: N/A

Re: TextInput setFocus method??

 

package
{
	import flash.display.Sprite;
	import flash.display.Stage;
	import qnx.ui.text.TextInput;
	
	public class PlayBookTest extends Sprite
	{
		public function PlayBookTest()
		{	
			var input:TextInput = new TextInput();
			
			addChild(input);
			
			stage.focus = input;
		}
	}
}

 

however, it doesn't seem to automatically bring up the virtual keyboard - at least  not in the simulator.  if that's what you want, which it probably is, i believe you'll have to wait until RIM updates the SDK with more support for the keyboard.

 


PlayBook Applications:
Drop Swatch
Developer
Posts: 297
Registered: ‎10-30-2010
My Device: PlayBook
My Carrier: other

Re: TextInput setFocus method??

[ Edited ]

Works great! It also fixes the bug of TextInput custom scrollrect not refreshing (unless clicked on)

Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook
My Carrier: N/A

Re: TextInput setFocus method??

does the keyboard automatically pop up for you?  i've been having problems with my simulator (QNX TestInput components are scaled up huge by default) so the keyboard not popping up for me might just be my simulator?


PlayBook Applications:
Drop Swatch
Developer
Posts: 297
Registered: ‎10-30-2010
My Device: PlayBook
My Carrier: other

Re: TextInput setFocus method??

Keyboard didnt work for me either. But it does have some sort of refresh effect on text box.
Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook
My Carrier: N/A

Re: TextInput setFocus method??

usually components are re-rendered by calling drawNow().

 

 

myTextInput.drawNow();

however the QNX components extend from their own QNX UIComponent class that doesn't have a drawNow() method but a draw() method

 

 

 

myQNXTextInput.draw();

 try that instead to refresh your TextInput object.

 


PlayBook Applications:
Drop Swatch
Developer
Posts: 297
Registered: ‎10-30-2010
My Device: PlayBook
My Carrier: other

Re: TextInput setFocus method??

[ Edited ]

I get 'call to a possibly undefined method' error for both of those methods.

Highlighted
Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook
My Carrier: N/A

Re: TextInput setFocus method??

[ Edited ]

ah... i just realized that method is protected, not public.

 

in that case, simply reseting it size to it's current size (no visual change) will call the draw() method for you.  doing so should re-render the component.

 

 

myQNXTextInput.setSize(myQNXTextInput.width, myQNXTextInput.height);

 

 


PlayBook Applications:
Drop Swatch