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
Contributor
soul2k
Posts: 29
Registered: ‎05-08-2011
My Device: Bold 9900 / Playbook

Hide Virtual Keyboard in SDK 3.0

In the 2.0 SDK, we were able to hide the virtual keyboard after clicking on a standard TextField by using

 

this.stage.focus = null;

 This does not seem to be working in 3.0.  Does any one know a new way to achieve this ?

 

Developer
Paratheo
Posts: 134
Registered: ‎04-25-2009
My Device: Z30

Re: Hide Virtual Keyboard in SDK 3.0

This is still working for me...

 

stage.focus = null;

Contributor
soul2k
Posts: 29
Registered: ‎05-08-2011
My Device: Bold 9900 / Playbook

Re: Hide Virtual Keyboard in SDK 3.0

[ Edited ]

This is the code I have running on the Dev Alpha OS 10.0.9.338

NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN,handleKeyDown);

...

private function handleKeyDown(e:KeyboardEvent):void
{
	if (e.keyCode == Keyboard.ENTER)
	{
		this.stage.focus = null;
	}
}

 

Could I be doing something wrong ?

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Hide Virtual Keyboard in SDK 3.0

What if you add the same event listener to the stage (after the item has been added to the stage)?
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Hide Virtual Keyboard in SDK 3.0

Also, did you confirm (via a trace statement) that the function is even being called?
Contributor
soul2k
Posts: 29
Registered: ‎05-08-2011
My Device: Bold 9900 / Playbook

Re: Hide Virtual Keyboard in SDK 3.0

[ Edited ]

I have confirmed that the code is being executed with trace statements surrounding the stage.focus = null code inside of the if statement.

 

Adding the listener to the stage produces the same result as nativeApplication.

The identical code resulted in hiding the keyboard on Dev Alpha OS 10.0.6 and PlayBook OS 2.0/2.1

 

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Hide Virtual Keyboard in SDK 3.0

Seems like you have exhausted everything. I would create a simple app to showcase this bug and submit it to RIM as an issue.
Contributor
soul2k
Posts: 29
Registered: ‎05-08-2011
My Device: Bold 9900 / Playbook

Re: Hide Virtual Keyboard in SDK 3.0

My best guess is that the stage.focus = null does not work anymore because the bb10 keyboard is now native and not in AIR anymore, meaning the focus does not even change when the keyboard appears.

 

Might be out of luck here until additions are made to the VirtualKeyboard API :smileysad:

Developer
Developer
mdd
Posts: 225
Registered: ‎01-17-2012
My Device: PB

Re: Hide Virtual Keyboard in SDK 3.0

I have the opposite problem: on simulator, soft keyboard not showing in dialogs, even though needSoftKeyboard = true.

 

Is this a known simulator limitation?

Retired
dmalik
Posts: 427
Registered: ‎02-22-2012
My Device: BlackBerry Z10, BlackBerry Dev Alpha C, BlackBerry PlayBook

Re: Hide Virtual Keyboard in SDK 3.0

This works for me:

addEventListener(FocusEvent.FOCUS_IN, focusInHandler, false, 0, true);

private function focusInHandler(event:FocusEvent):void
{
stage.focus = null;
}

 

 

Follow me on Twitter: @dustinmalik
-----------------------------------------------------------------------------------------------------
Keep up to date on BlackBerry development: http://devblog.blackberry.com/