Good afternoon,
I have a small problem when using the native Android bridge's TextFields. In one screen, I have such a textfield at the bottom of the screen with a (Gideros) send-button next to it. However, when one clicks on the field and thus opens up the keyboard, only the send-button moves up; the native textfield gets hidden beneath the keyboard. Why doesn't that move as well? Or if this is impossible, how can I handle the keyboard-open event myself?
Thanks in advance,
-Vincent
Comments
cool I have not thought of possibility of this problem
Well the easy solution would be to create a scrollable view (either in Gideros or Android) and let user to scroll the textfield up
in the meantime I'll check if it can be handled automatically, or better how other apps are handling it
Again, the best solution would be to reposition the android elements in the same fashion as the native gideros elements, and a best alternative would be the option to handle a keyboard-open event or something like that.
I have another issue now though. When using an OptionsDialog, with e.g. 4 options (in of course a plain array), the device will show the first option's name 4 times. The event handling does return the correct name though (event.optionText, but this is Gideros native code). So something must go wrong in setting the items for display (build:setItems). This happens through 'String.newArray(options)', and I have no idea what that does, and it seems to fail.
Thanks in advance for the help,
-Vincent
About the text input issue, unfortunately I could not find on displaying keyboard event on Android, closest I came was on text input focus changed, but it is far from what is needed, so currently I still don't have a solution for that.
And I just tried out when placing text input somewhere in the bottom of the screen, so even if I input the character it still does not jump up as you described.
That got me thinking why we get different results and I searched more and found that you can actually control the default behavior from AndroidManifest
http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
in your case setting
android:windowSoftInputMode="adjustPan" attribute on activity
if it is not provided, what system does depends on Android version and selected theme, thus us having different behaviors
Hope that helps
-Vincent
As mentioned, even without the adjustPan setting, the native Gideros elements do shift upwards (e.g. our submit button), so the problem really lies in the repositioning of the native element, which seems unrelated to that setting anyway.
I hope you can find a solution to this; thanks in advance!
But let me try more tests
-Vincent
Firstly I was wrong the right value to use for soft input was
So firstly I do positioning using relative views, which should not be bad, but in this case the text input does not appear after first input. If I use gravity and margins instead (will have to rewrite ui lib to do that later), the text input appears correctly on top after first input. But initial it is also hidden under keyboard.
Basically it is a bug in Android, which incorrectly places the input when you are using activity in full screen (as Gideros does), thus first solution:
1) Remove fullscreen by removing
So next solution
2) I found most of people seem to be using is to wrap all contents in ScrollView, which they say should also work in fullscreen mode. This is something I'm still working on and trying to use, but for now unsuccessfully, it did not work with all my attempts.
3) third solution I thought could be used is to input something on focus change, but setText function seems to be working differently from keyboard input, so the input only jumps to the top, when something on the keyboard was pressed.
4) thinking of some kind of api to control view offsets, but that won't help if there are no keyboard show/hide events, etc. So this won't work too.
Bottom line
I will keep experimenting with ScrollView and looking for other solutions.
But if that fails, I will rewrite lib to Gravity positioning, so at least input is shown after first input and developers would have an option to remove fullscreen to make it behave normally
So as you see, there is a progress, but no solution yet.
Not using fullscreen is indeed not a viable option for us as well. However, if it works on first input on any device, at least part of the problem is solved, so that sounds good. I hope it works out with the ScrollView though
http://stackoverflow.com/questions/12422566/android-adjust-scrollview-when-keyboard-is-up
It seems you need all (!) three of those flags in combination with a scrollview to make it work?
According to Android documentation using multiple 'state*' or 'adjust*' values has undefined results. You should use 'one state', 'one adjust' or 'one state and one adjust' values.
still worth to try
hmm need to think about it
And about avatar selection, the media plugin to select images from gallery or camera is coming up quite nicely
http://www.giderosmobile.com/forum/discussion/comment/32833#Comment_32833
Any ETA on the positioning issue though? :P
"local touchProxy = native.createProxy("android.view.View.OnTouchListener", {onTouch = function(view,edit)
local event = Event.new("onTouch")
event.text = event:toString()
self:dispatchEvent(event)
end})
self._core:setOnTouchListener(touchProxy)"
However, this causes the app to fully crash on the first createProxy call. Do you have any hints for me? :P
android.view.View.OnTouchListener
to this
android.view.View$OnTouchListener
This is how they relate internally
and unfortunately, the field only jumps up after first letter, when you don't set width to it (same behavior in old version)
But on the bright side, I added one functionality that bridge was missing, and now all widgets will take up for one view lesser, making it faster to load, and there probably be easier installation, as there won't be any layout changes in activity
just let me test that tomorrow a little more
And it behaves the way you described, but only when you don't set the dimensions of the text box.
Sorry, but it seems it is nothing I can do there, android fullscreen bug
"local touchProxy = native.createProxy("android.view.View$OnTouchListener", {onTouch = function(v,event)
self:dispatchEvent(event)
return false
end})
self._core:setOnTouchListener(touchProxy)"
This almost works; on the touch event itself, the following exception is generated:
"01-26 15:26:07.032: E/AndroidRuntime(2209): java.lang.NullPointerException: null result when primitive expected $Proxy1.onTouch(Native Method)"
So it does not seem to properly pass the 'return false' there; any suggestions?
You could try instead:
"replyinput:addEventListener("onClick",function()
local inputDialog = TextInputDialog.new("Reactie","Geef uw reactie:","","OK")
inputDialog:addEventListener(Event.COMPLETE,function(event)
self.replyinput:setText(event.text)
end)
inputDialog:show()
end)"
Which works in combination with calling setFocusable(false) on the textinput's core element. It's a pity the Android behavior is so weird and inconsistent on this.
A final question: is it possible to hide the user's keyboard programmatically in Gideros?