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

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

QNX Keyboard Control [UNOFFICIAL]

in an attempt to make my code as portable as possible, i try to avoid using QNX components, in this case the TextInput component.


the downside to using a standard AS3 TextField instead of QNX TextInput is that it appears RIM is currently heading towards tightly integrating their QNX TextInput component with the QNX Keyboard.  while the SDK is still in beta and a Keyboard API is basically non-existant at this point, it's now at least possible to assign a KeyboardType and ReturnKeyType to a specific QNX TextInput component, but it's not (officially) possible to do the same for an AS3 TextField.


the following code addresses this issue by allowing you to specify both a KeyboardType and ReturnKeyType for a standard AS3 TextField.  also, the return key on the QNX Keyboard also now works thanks to a dirty little hack, which is unfortunate, but hey... i'll take what i can get.


additionally, the showKeyboard() and hideKeyboard() functions allow you to access the QNX Keyboard without having to set focus on or remove focus from a TextField / QNX TextInput or by swiping up from the bottom left corner of the bezel.



WARNING:  The following is not officially documented and may not work with future SDK updates



	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFieldType;
	import flash.events.TextEvent;
	import qnx.input.IMFConnection;
	import qnx.input.IMFKeyboardOptions;

	[SWF(height="600", width="1024", frameRate="30", backgroundColor="#444444")]
	public class PlayBookTest extends Sprite
		//QNX Keyboard Type Constants
		public static const DEFAULT:String = "default";
		public static const PIN:String = "pin";
		public static const PHONE:String = "phone";
		public static const EMAIL:String = "email";
		public static const URL:String = "url";
		//QNX Return Key Type Constants
		public static const SEARCH:String = "enter.search";
		public static const RETURN:String = "enter.default";
		public static const SEND:String = "enter.send";
		public static const JOIN:String = "enter.join";
		public static const GO:String = "enter.go";
		public static const DONE:String = "enter.done";
		public static const NEXT:String = "enter.next";
		public static const SUBMIT:String = "enter.submit";
		public static const CONNECT:String = "enter.connect";
		public function PlayBookTest()
		private function init():void
			//Create AS3 TextField
			var as3tf:TextField = new TextField();
			as3tf.type = TextFieldType.INPUT;
			as3tf.width = 500;
			as3tf.height = 25;
			as3tf.border = true;
			as3tf.borderColor = 0xFFFFFF;
			as3tf.background = true;
			as3tf.backgroundColor = 0x0000FF;
			as3tf.textColor = 0xFFFFFF;
			as3tf.multiline = true;
			//Position AS3 TextField
			as3tf.x = stage.stageWidth / 2 - as3tf.width / 2;
			as3tf.y = stage.stageHeight / 4 - as3tf.height / 2;
			//Assign QNX Keyboard Options To AS3 Text Field
			IMFConnection.imfConnection.setKeyboardOptions(as3tf, new IMFKeyboardOptions(EMAIL, CONNECT, null));
			//Add AS3 TextField To Stage
			//Listen For QNX Keyboard Return
			as3tf.addEventListener(TextEvent.TEXT_INPUT, keyboardReturnHandler);
		//Handle QNX Keyboard Return
		private function keyboardReturnHandler(evt:TextEvent):void
			if	(evt.text == "\n")
				stage.focus = null;
				trace("QNX Keyboard Return Button Pressed");
		//Show QNX Keyboard
		private function showKeyboard():void
		//Hide QNX Keybaord
		private function hideKeyboard():void



PlayBook Applications:
Drop Swatch