Dismiss SoftKeyboard in Flex Mobile
Asked Answered
L

2

0

The Flex InteractiveObject has has a requestSoftKeyboard() method that pops up the Soft Keyboard.

How can I do the opposite and send it back?

Thank you.

Limicolous answered 29/8, 2011 at 14:25 Comment(0)
A
1

With Flex 4.6, you can dismiss by setting

stage.focus = null;

Please read more here: open soft keyboard in a mobile Flex application

Austerlitz answered 14/10, 2014 at 10:12 Comment(0)
P
1

For example, say your InteractiveObject is a TextInput, then you can keep it from popping up with the following:

private function onActivating(event:SoftKeyboardEvent):void 
{
           event.preventDefault();
}           


<s:TextInput softKeyboardActivating="onActivating(event)" />

Or you can use

<s:TextInput needsSoftKeyboard = "False"/>

EDIT:

You can send it back with the following:

Listen for the event when you want it to close (like hitting the "enter" key) and then use the setFocus property to change the focus to another component:

private function CloseKeyboard():void
{
hidesoftkeyboard.setFocus();
}`

<s:TextInput id="txtinput"/>
<s:Button id="hidesoftkeyboard" click=CloseKeyboard();>

UPDATE

Following the 4.6 update to Flex - there are new softkeyboard techniques chronicled here.

Poniard answered 29/8, 2011 at 15:24 Comment(3)
Thanks, but I need a way to dismiss it programatically. Not prevent it from appearing.Limicolous
Hm, that's kind of a hack. I'll give it a go and let you know. Thanks.Limicolous
Yeah, it is a hack - but the problem is Flex doesn't deal with the native Android API, and has to cross-reference. Every release gets better, but we're still stuck on a few of these pesky issues. Check this for more info.Poniard
A
1

With Flex 4.6, you can dismiss by setting

stage.focus = null;

Please read more here: open soft keyboard in a mobile Flex application

Austerlitz answered 14/10, 2014 at 10:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.