Skip to main content
Inspiring
October 12, 2011
Answered

Air3.0 and the softKeyboard not appearing on Stage.focus = InputTextfield on iOS

  • October 12, 2011
  • 6 replies
  • 5432 views

In RC1 of Air3.0 and earlier versions of air, I could summon the softkeyboard for the iPhone/iPad by doing this.

Create an inputtext field, set it's width and height to 0 to hide it

Then, when I want to show the soft keyboard, simply do:

stage.focus = txtCapture;

Where txtCapture is my input text field. When I wanted to hide it, I would simply set the stage.focus to any other object.

This worked great until 3.0 was offically released and now the softkeyboard does not appear on the set focus, it ONLY appears if you manually click on the input field itself, but since you can't use center alignment or any other formatting on input text fields for the iOS, I can't let it be seen


Anyone have any idea how I can get the softkeyboard to appear?

This topic has been closed for replies.
Correct answer Nimisha1

Hi Dave,

stage.focus = txtCapture won't  work after 2.6 and it is known  .

>>how I can get the softkeyboard to appear

Please use :

txtCapture.needsSoftKeyboard= true;

txtCapture.requestSoftKeyboard();

Above APIs will definitely work .

Thanks,

Nimisha

6 replies

Participant
October 5, 2012

I think we're experiencing an issue with this:

We're trying to use the iCade cabinet with an iPad and a Flash application (though this shouldn't affect the problem as the problem can be replicated without any connection or involvement with the iCade unit).

To make sure that the app is able to respond to the iCade's input (which is a simulation and transmission of certain keystrokes for each input), we create a TextField set off-screen and keep it visible (as this seems to be a requirement), and then we set the stage focus to that TextField. We also invoke requestSoftKeyboard on the TextField.

I learnt from this thread that setting stage focus isn't required, but I had the same issue as someone else here, in that I read that requestSoftKeyboard isn't supported on iOS - the documentation could be more clear about exactly what this means, like it's been explained here. Besides, setting stage focus should be fine, and not the cause of the issue I'm about to explain.

We have needsSoftKeyboard=false on the TextField, and after setting that, we request the soft keyboard. The upside is that this appears to prime the runtime to respond to keyboard input regardless of where it's coming from, and the keyboard usually stays hidden. Our problem is that, sometimes on app startup and sometimes up to 15 minutes of idle time later, the soft keyboard appears without prompt or user input.

Is this intended behaviour? We're only developing this application for iOS, and aren't sure if the issue is perhaps to do with the iOS soft keyboard.

We also tried handling the soft keyboard events (such as Activate, Activating and Deactivate) to attempt to stopImmediatePropagation and preventDefault. These seem to conflict with our setting focus in the first place, so I don't think we can make use of these. We tried only preventing the event when our target TextField already has focus, but this didn't work, and I think at this point we were really just shooting in the dark!

Adobe Employee
October 5, 2012

Can you share your project (if possible without iCade unit) at nehgupta@adobe.com, so that we can reproducible the issue at our end?

-Neha

Participant
October 18, 2011

I use the following codes on iOS and it works fine.

public function Main() {

   ...

   txt.type = TextFieldType.INPUT;

   txt.needsSoftKeyboard = true;

   txt.addEventListener(FocusEvent.FOCUS_IN, onTxtFocusIn);

   ...          

}

private function onTxtFocusIn(event:FocusEvent):void {

   ...

   txt.requestSoftKeyboard();

   ...

}

Nimisha1
Nimisha1Correct answer
Participating Frequently
October 18, 2011

Hi Dave,

stage.focus = txtCapture won't  work after 2.6 and it is known  .

>>how I can get the softkeyboard to appear

Please use :

txtCapture.needsSoftKeyboard= true;

txtCapture.requestSoftKeyboard();

Above APIs will definitely work .

Thanks,

Nimisha

Inspiring
October 18, 2011

I'll give it a try, but the documentation says that requestSoftKeyboard() is not supposed on the iOS? Are you saying this is not true now, that it does support it?

Participating Frequently
October 18, 2011

@DaveGallant, The requestSoftKeyboard() method isn't supported on iOS, except for TextField objects. At the time I wrote the docs you cite, calling requestSoftKeyboard() for a text field was redundant since assigning the stage focus to the text field raised the keyboard on its own and you had to set the focus before calling requestSoftKeyboard(). Now calling requestSoftKeyboard() is required for TextField objects. (And you don't have to set focus beforehand anymore, it is set automatically by the keyboard request call.)

Here's an example that works in AIR 3: http://recycledinformation.blogspot.com/2011/10/custom-text-entry-on-ios.html