When I have a bunch of textfields in a scrollview and I start editing one of the lower textfields, the virtual/soft keyboard gets displayed on top of the textfield I was editing.
This is under openfl-html5 and then tested on android.
I guess it’s more of a backend/openfl issue, but I was wondering if there was a solution in place I’m overlooking?
Otherwise I’ll probably try to get softKeyboardActivate and do a ensureVisible call.
There is nothing in haxeui to explicitly handle this. Though i would be interested in what solution there is, maybe it could go into a / all the backends.
So there was no real solution in place. The Stage or App height does get smaller when the virtual keyboard appears. So you could go through resize events.
I also tried Focus events, but focus seemed a bit strange, like focus jumping back after using a dropdown.
In the end I simply called ensureVisible in the MouseUp Event of the TextField. Though I did call ensureVisible in a Timer, because the resize occurred pretty late.
ta.registerEvent(MouseEvent.MOUSE_UP, function (e:UIEvent) {
Timer.delay( function() {
var tmp:Component=ta.parentComponent;
var child:Component=ta;
while (tmp!=null) {
if (Std.is(tmp,haxe.ui.core.IScrollView)==true) {
cast(tmp,haxe.ui.core.IScrollView).ensureVisible(child);
}
tmp=tmp.parentComponent;
}
}, 500);
});
The while loop is probably superfluous and should probably be reversed if used. I just wanted to see some change while testing.
It gets more complicated though when the app has little height (virtual keyboard) and the textfield has multiple lines. Ensurevisible does not ensure the caret is visible. It just tries to show the component.
So you’re typing below the virtual keyboard again in some cases.