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
Posts: 33
Registered: ‎12-23-2010
My Device: Not Specified
My Carrier: vodaphone
Accepted Solution

Dismissing the keyboard...

A couple questions on the keyboard, is there a method to dismiss it? Don't see one in the API Reference. Also working with... 

 

myInput.returnKeyType = ReturnKeyType.JOIN;

 

I get an undefined property error, and I don't see the ReturnKeyType class when I goto import qnx.ui.text...

 

Last question, if I do get ReturnKeyType working, can I listen for a return key event of some sort and call a custom function? Seems like the TexInput / Keyboard classes are lacking?

 

 Thanks for any help guys!

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

Re: Dismissing the keyboard...

From some other threads, I recall people saying that there is not an API to show or hide the keyboard at this time.

Developer
Posts: 29
Registered: ‎11-14-2010
My Device: Playbook

Re: Dismissing the keyboard...

 

Hi Nicholas,
It seems that returnKeyType and keyboardType properties of TextInput are going to be implemented in next version of SDK. As I understood from online API documentation the returnKeyType just defines what label will be displayed on Virtual Keyboards Enter key.
As for the dismissing the virtual keyboard, that is supported by the OS. It reacts on focus in and out of text fields.
Here is the sample how you can hide keyboard after user presses the ENTER key:
package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	
	import qnx.ui.text.TextInput;
	
	public class KBDSample extends Sprite
	{

		private var _ti:TextInput;
		
		public function KBDSample()
		{
			super();
			
			// support autoOrients
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			_ti = new TextInput();
			_ti.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
			addChild(_ti);
		}
		
		protected function onKeyUp(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.ENTER) {
				stage.focus = null;
			}
		}
	}
}

 

 

Contributor
Posts: 33
Registered: ‎12-23-2010
My Device: Not Specified
My Carrier: vodaphone

Re: Dismissing the keyboard...

miroslav, thats exactly what I need to know. I kinda assumed it would deal with focus, seeing how when a text input receives focus the keyboard automatically appears. Was just stuck in my iOS ways and having a explicit function for dismissing it. Thanks!

 

Appreciate it, this forum has been very helpful.

Developer
Posts: 107
Registered: ‎11-20-2009
My Device: Tegra 2 Android tablet and Playbook
My Carrier: Rogers

Re: Dismissing the keyboard...

[ Edited ]

Focus is partial solustion, you cannot rely on focus especially if you displayed keyboard by swipe at the left bottom corner of the screen....

http://riahut.com
Developer
Posts: 29
Registered: ‎11-14-2010
My Device: Playbook

Re: Dismissing the keyboard...

Hi ectar,

 

I'm not sure what you meant by that?

If you tried the sample code you would see that keyboard will hide after pressing the Enter key while typing in TextInput even if you brought it up before clicking on TextInput by using bottom left swipe. 

 

On the other hand, if the user is intentionally brought up the keyboard with swipe, you can assume that he would also know how to close it by clicking on the bottom left button on the keyboard.

 

I don't think that Nicholas was trying to prevent keyboard from ever showing up since that would be useless when the device doesn't have other input method (at lest not right now).

 

Best regards.