Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This will not work on <renderMode>direct</renderMode> #1

Open
gilamran opened this issue Sep 17, 2013 · 11 comments
Open

This will not work on <renderMode>direct</renderMode> #1

gilamran opened this issue Sep 17, 2013 · 11 comments

Comments

@gilamran
Copy link

Most of the apps/games these days use Starling, so they all use direct mode, and not auto (cpu). When using direct I get size 0 all the time.

@marcorei
Copy link

@gilamran I got the same problem. Did you find a solution how to get the correct soft keyboard size?

@gilamran
Copy link
Author

That was more than a year ago... I don't remember sry.

@ghost
Copy link

ghost commented Jun 30, 2015

I have the same problem. Rendering in direct and on SOFT_KEYBOARD_ACTIVATE the value for Height is 0 and for Y is [fullScreenHeight], so basicly always like it were hidden. I thought this ANE solved exactly this problem? I'm confused.

EDIT: What i just noticed is, that while I use getKeyboardHeight() on SOFT_KEYBOARD_ACTIVATE is always giving me 0, when I wait 200-1000ms and recheck the value, it actually gives me a usefull value back. Therefore a workaround for now could be to tween the Input-Textfield intoplace and onComplete recheck the height in hope that now correct values are available.

@marcorei
Copy link

In our case, there were actually two problems on Android. The first one was the one you just mentioned. The second one was that when setting setSoftInputMode to 48 (adjust nothing), the value for height would always be 0, even after some timeout.

Though, when setting setSoftInputMode to 32 (pan) and waiting for some frames, <renderMode>direct</renderMode> did not seem to be an issue anymore.

So our workaround now is to temporarily set the setSoftInputMode to 32 (pan) right after the softkeyboard activate event, and to move the StageText in the visible area so that no pan occurs.
We then check every frame for a change in the Height value. As soon as we got the height, we set setSoftInputMode back to 48 (adjust nothing) and adjust the layout according to the height.

We also cache the height value for every input type so that we only have to do this procedure once per app lifecycle.

@AntonPieter
Copy link

Looks like a good workaround. What value did you use for , and what do you mean by "to move the StageText in the visible area so that no pan occurs"?

@AntonPieter
Copy link

Ah, some text disappeared. It should say "What value did you use for softKeyboardBehavior (in the application description xml)."

@marcorei
Copy link

marcorei commented Sep 6, 2015

softKeyboardBehavior was set to "none" <softKeyboardBehavior>none</softKeyboardBehavior>. Though this should not matter because you can change this behavior via ANE-KeyboardSize at runtime.

When the input is not hidden by the keyboard then the screen does not pan, even when setSoftInputMode is changed to 32 (pan) instead of 48 (none). So by "move the StageText in the visible area" I meant: set the y coordinate of the input to a value that puts the input in the upper half of the screen which will most likely not be hidden by the keyboard.

@AntonPieter
Copy link

Great! And does this work for both Android and iOS? Since iOS returns a correct value for softkeyboardrect (well, before iPhone 6...). What I mean is can we trust the change in height (I presume you mean the MeasureKeyboard.getInstance().getKeyboardHeight();?) will always take place, or should we check if it is not 0?

@marcorei
Copy link

marcorei commented Sep 6, 2015

We did not use this ANE to get the keyboard height on iOS, only on Android. In the source of this ANE you'll see that it will always return "null" on iOS.

Starling.current.nativeStage.softKeyboardRect.height did work well on iOS for us. Though I can not tell you if you can trust this value to be correct on all iOS devices.

@AntonPieter
Copy link

OK, great. I’ll check if it is Android. and will use this method, when it is. Otherwise, I will use softKeyboardRect. Although I am not sure if it will return the correct value on the iPhone 6.

Thanks, and I will report back if this works.

Op 6 sep. 2015, om 17:06 heeft Markus Riegel [email protected] het volgende geschreven:

We did not use this ANE to get the keyboard height on iOS, only on Android. In the source of this ANE you'll see that it will always return "null" on iOS https://github.com/freshplanet/ANE-KeyboardSize/blob/master/ios/ANEKeyboardSize/KeyboardSize.m#L29.

Starling.current.nativeStage.softKeyboardRect.height did work well on iOS for us. Though I can not tell you if you can trust this value to be correct on all iOS devices.


Reply to this email directly or view it on GitHub #1 (comment).

@AntonPieter
Copy link

And reporting back. It works! Thanks!

Op 6 sep. 2015, om 19:02 heeft Anton Pieter van Grootel [email protected] het volgende geschreven:

OK, great. I’ll check if it is Android. and will use this method, when it is. Otherwise, I will use softKeyboardRect. Although I am not sure if it will return the correct value on the iPhone 6.

Thanks, and I will report back if this works.

Op 6 sep. 2015, om 17:06 heeft Markus Riegel <[email protected] mailto:[email protected]> het volgende geschreven:

We did not use this ANE to get the keyboard height on iOS, only on Android. In the source of this ANE you'll see that it will always return "null" on iOS https://github.com/freshplanet/ANE-KeyboardSize/blob/master/ios/ANEKeyboardSize/KeyboardSize.m#L29.

Starling.current.nativeStage.softKeyboardRect.height did work well on iOS for us. Though I can not tell you if you can trust this value to be correct on all iOS devices.


Reply to this email directly or view it on GitHub #1 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants