Android, HaXeNME, soft keyboard, remaining screen real estate

583 views
Skip to first unread message

Robert Flesch

unread,
Nov 9, 2012, 12:19:50 PM11/9/12
to haxe...@googlegroups.com
Pre thanks for looking at this.

I am doing my first cross platform app using HaXeNME and I can't find much documentation on how to effectively use the soft keyboard on Android phones (or a more general solution).
Goal is to have a text input field at the bottom of the screen that can be used for a search.
So the field is there, when I touch it, the soft keyboard comes up. Great.

First issue I notice is there is no way to hide the soft keyboard once it comes up.
Hitting the return key doesn't effect it.
Do I need to put a special handler in to hide the keyboard when return is hit?
Any examples out there?

Secondly the soft keyboard hide my TextField.
So it seem that the best approach would be to watch for an event when the soft keyboard has appeared.
When this event is triggered, I would create a smaller "TextField only" window which would take up the remaining space on the screen.
Can you determine the size of the soft keyboard? or how much screen space is remaining?
Any ideas on how to approach this.

I would think this is a fairly common problem, but I am not seeing anyone else discussing it.

bob

Achmad Aulia Noorhakim

unread,
Nov 10, 2012, 8:35:05 AM11/10/12
to haxe...@googlegroups.com
Hi, I did have the same problem as you have right now. NME support for softkeyboard is rather lacking right now, it still missing API implementation from AIR for Mobile.

Somethings that might help:
- To track whether softkeyboard is visible or not, you can watch the textfield focus (on focus/lost focus) and assume when the textfield is focused, the softkeyboard is visible. Then from there you can calculate your textfield Y position is it below the keyboard treshold (I use half the screen height), if it is, push the whole stage/scene up, so the textfield is visible. When the softkeyboard is invisible again (textfield lost focus) you can return its position to its original position.

- About the return key, the softkeyboard will be hidden itu the user touches area outside the keyboard OR the back button. My problem was detecting the back button when the softkeyboard is visible, because it throw out a slightly different keyboard event/code. You can edit/modify the GameActivity.java and use the template tag in the NMML to add the functionality (return key hide the keyboard).


Hugh

unread,
Nov 11, 2012, 11:34:15 PM11/11/12
to haxe...@googlegroups.com
Hi,
Yes, this was on my todo list - but have not got there yet.

Hugh

Achmad Aulia Noorhakim

unread,
Nov 12, 2012, 12:20:28 AM11/12/12
to haxe...@googlegroups.com
Good to hear ! :D

Robert Flesch

unread,
Nov 14, 2012, 11:06:55 AM11/14/12
to haxe...@googlegroups.com
Trying to do it manually is a pain.
If you want to support mobile phones this is a must have.


>You can edit/modify the GameActivity.java and use the template tag in the NMML to add the functionality (return key hide the keyboard).
Achmad could you elaborate a bit more on this. I am not that familiar with the java code underlying the haxe code base.
In other words, huh?

bob

miles.m...@gmail.com

unread,
Feb 4, 2013, 1:31:28 AM2/4/13
to haxe...@googlegroups.com
Has there been any update on the soft keyboard issue since November?  I'm working on a cross-platform app as well and am running into the same issue as Robert.

Joshua Granick

unread,
Feb 4, 2013, 7:35:51 PM2/4/13
to haxe...@googlegroups.com
Does anyone know if Flash/AIR has an existing API to be able to access further features of a virtual keyboard, such as showing, hiding or determining the size? Or do we need to make up a new API for it?
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haxelang+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



Rocks Wang

unread,
Feb 21, 2013, 8:32:42 AM2/21/13
to haxe...@googlegroups.com
Hey, any update for this issue?
I also encountered this problem, I was expected that setting android:windowSoftInputMode="adjustPan" in AndroidManifest should solve this problem but failed, the NME view is not pan-up as a normal view. I also overrided onLayout() method in MainView, it's called once on soft-keyboard was shown up, however the first parameter is always false.
Why NME MainActivity as a normal Android activity does not support setting of android:windowSoftInputMode?  Is it because GLSurfaceView does not support panning at all?

在 2012年11月10日星期六UTC+8上午1时19分50秒,Robert Flesch写道:

Julian Liebl

unread,
Jul 17, 2013, 6:33:59 PM7/17/13
to haxe...@googlegroups.com
Hi,

I just encountered similar issues. But was able to solve them at least when it comes to android. The only way I found to determine if the virtual keyboard is active or not -> https://github.com/jujulian1987/MobTexHX/blob/master/src/java/MainActivity.java

You can check out the working samples here: https://github.com/jujulian1987/MobTexHX

It's a dirty workaround but it works. I will try to improve the repository over time. 

Cheers,
Julian


Reply all
Reply to author
Forward
0 new messages