Detect keyboard height

I am using “CoronaWindowMovesWhenKeyboardAppears=true”, and it pushes the entire corona canvas up the height of the native keyboard (IOS). I was wondering if there was a way to find out that native keyboard height or to only have certain objects move up during the “CoronaWindowMovesWhenKeyboardAppears=true” event. 

You cannot get this information.

Rob

I’m trying to use the CoronaWindowMovesWhenKeyboardAppears options for both iOS & Android.

Initially I was using native.newTextField, but then I needed to change to native.newTextBox so I could have longer text entry.

The textBox appears to work fine on Android (it scrolls up and behaves pretty similarly to the textField). However, on iOS the scroll up is not working if I use a textBox. If I switch back to a textField it works.

It looks like the textBox implementation is supposed to work on both iOS and Android.

Is anyone else having problems for TextBoxes on iOS? Has something changed that might have made it fail?

Looks like I’m going to have to switch back to using a TextField on iOS unless this is fixed.

Note: currently using Version 2015.2675 (2015.7.7)

For those who have read this post and are:

  • Confused about how to write code that does this
  • Don’t understand the differences between iOS and Android
  • Do not know how to handle fields that slide off screen

Download this example and run it on your device:

http://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/10/keyboardPanning.zip

https://www.youtube.com/watch?v=hLbUW0ekuRQ&feature=youtu.be

By default, line 7 in main.lua is set to ‘true’.   This tells the example to automatically cycle through the focused fields so you can watch how the devices handle panning and off-screen fields.  Turn it to false if you want to interact with the example.

local enableAutoFocus = true

Please note: On iOS, if a field slides offscreen, you can access it by setting the keyboard focus first to ‘nil’, then to the field you want to access.  On android you do not want to set the focus to ‘nil’ or the keyboard will wiggle a bit which is ugly.

-Ed

Same issue here. Also using a textbox. Tried giving the iOS panning a go but it isn’t working for me neither on device

This is an experimental feature and we know there are issues on iOS. I don’t know if textBoxes are supposed to be included or not.

Rob

I still can not understand why were not allowed to just get the keyboard height on iOS, when the alternative clearly isn’t even working. The panning feature sacrifices so much in the name of *one* solution that kind of works on all platforms.

How about one solution that works perfectly on iOS forever, and then whatever solution for Android on Android? Why isn’t it being implemented this way?

We try to keep Android and iOS platforms as close to possible and this is simply not something we can get on Android.

Rob

Is there a fix for this scheduled any time soon?

No. We won’t be adding support for this in the near future. It’s impossible to get this value on Android. This is why we introduced panning.

Sorry I meant to say a fix for the panning feature. Because we’d be able to go with anything if it would just work with textboxes. As for now though without the panning support, it just looks pretty bad and it’s difficult to design something that’ll work well.

Panning is fully operational on Android I believe. On iOS there are circumstances where it doesn’t work, the main one being on a multi-orientation app. So if you can do Portrait only or Landscape only, panning should work for you, though there may be a few other bugs.

Rob

We’re mainly having issues with it not working at all textbox. Our app is only in portrait mode and does not support multi-orientations. Yet with the panning implemented when we hit the textbox, it does not pan at all. This is on iOS.

I don’t know if we have it working with TextBoxes, and we have working on other things, it’s not something we will likely get to in the near future. Add it to a display group, scroll it to the top half of the screen.

Rob

Hello, is there a way to calculate the height that the screen moved up when panning to show the keyboard. I am implementing a chat feature and I would like to keep the back button at the very top when the keyboard slides up but the entire view moves up therefore moving the back button off the screen.

Also, native.newTextField pans for me but native.newTextBox() does not.

Correct. Only native.newTextField pans.  You can make your scrolling area small enough that it doesn’t go all the way to the top and have your back button bar stay on the screen.

Rob

I am using “CoronaWindowMovesWhenKeyboardAppears=true”, and it pushes the entire corona canvas up the height of the native keyboard (IOS). I was wondering if there was a way to find out that native keyboard height or to only have certain objects move up during the “CoronaWindowMovesWhenKeyboardAppears=true” event. 

You cannot get this information.

Rob

CoronaWindowMovesWhenKeyboardAppears=true

Rob, How can i detect offset of view when my textfieild is focused?

You should be able to get the .x and .y of the text field.

Rob