Detecting When Android Keyboard Is Cancelled By Back Key

If you detect the back button why not call the API that dismisses the keyboard: native.setKeyboardFocus( nil )

See: https://docs.coronalabs.com/api/library/native/setKeyboardFocus.html

Rob

A better solution would be to set up your app window to be “panned” by the Android OS when the virtual keyboard covers up the TextField/TextBox that has the focus.  Corona has an undocumented “build.setting” feature that allows you to enable this.  Have a look at the following forum post (link below) for more details.

   https://forums.coronalabs.com/topic/50905-detect-keyboard-height/?p=272745

Just be aware that enabling this panning feature has one consequence where the top status bar is no longer overlaid on top of your app.  Instead, the app window’s height (for portrait apps) will be made smaller to fit under it, assuming that you are displaying a status bar at all.

Hi Joshua,

Thanks for your help, 

I implement “coronaWindowMovesWhenKeyboardAppears” feature in build.setting and it works to shift view above keyboard and to set it back as keyboard focus sets to nil…

Also it has content scaling issue as u pointed out.

I tested it on androids…
In Android 5.0 or above it works fine. No content scaling problem or anything i noticed. works as charm…
But in Android 4, it scales down contentHeight and contentWidth of view…

“coronaWindowMovesWhenKeyboardAppears” feature works great. But if it may also fixed on Android 4 or lesser. Then it would be much appreciated.

Regards: Sajid Zeb

The content scale will only change if the window width/height changes.  That’s how it’s supposed to work because it ensures that your app’s content can fit onscreen.  Is your app actively hiding/showing the top status bar dynamically?  If so, then that will cause the height of your app to change, thus causing the content scale to change.

Joshua, No my app not hiding/showing the top status bar dynamically… Status bar is present there at top smoothly. and my view scaled at start… Not with any jerk as it seems to be scaled before rendering.

Then whole of my app run in scaled version throughout the scenes. not scaled or rescaled anymore.

Hi Rob and All,

Is this problem resolved yet??
Can keyboard dismiss event by android back button for now? because i am also moving my field above from keyboard so that they can not hide behind keyboard. And i give transition back to previous place to fields on screen touch…

But when i press device back button, it closes keyboard but my scene remains there…

I cannot find any event of keyboard dismiss or anything like this to get me help to achieve this…

Thanx in advance
Sajid Zeb
 

If you detect the back button why not call the API that dismisses the keyboard: native.setKeyboardFocus( nil )

See: https://docs.coronalabs.com/api/library/native/setKeyboardFocus.html

Rob

A better solution would be to set up your app window to be “panned” by the Android OS when the virtual keyboard covers up the TextField/TextBox that has the focus.  Corona has an undocumented “build.setting” feature that allows you to enable this.  Have a look at the following forum post (link below) for more details.

   https://forums.coronalabs.com/topic/50905-detect-keyboard-height/?p=272745

Just be aware that enabling this panning feature has one consequence where the top status bar is no longer overlaid on top of your app.  Instead, the app window’s height (for portrait apps) will be made smaller to fit under it, assuming that you are displaying a status bar at all.

Hi Joshua,

Thanks for your help, 

I implement “coronaWindowMovesWhenKeyboardAppears” feature in build.setting and it works to shift view above keyboard and to set it back as keyboard focus sets to nil…

Also it has content scaling issue as u pointed out.

I tested it on androids…
In Android 5.0 or above it works fine. No content scaling problem or anything i noticed. works as charm…
But in Android 4, it scales down contentHeight and contentWidth of view…

“coronaWindowMovesWhenKeyboardAppears” feature works great. But if it may also fixed on Android 4 or lesser. Then it would be much appreciated.

Regards: Sajid Zeb

The content scale will only change if the window width/height changes.  That’s how it’s supposed to work because it ensures that your app’s content can fit onscreen.  Is your app actively hiding/showing the top status bar dynamically?  If so, then that will cause the height of your app to change, thus causing the content scale to change.

Joshua, No my app not hiding/showing the top status bar dynamically… Status bar is present there at top smoothly. and my view scaled at start… Not with any jerk as it seems to be scaled before rendering.

Then whole of my app run in scaled version throughout the scenes. not scaled or rescaled anymore.