Hi Guys
I am in the process of converting some old code to B4X using the new XUI views, in particular B4XFloatTextField.
I am now having problems with the keyboard hiding the views (hopefully it's something simple that I have missed).
I converted a form which used the older textField view to B4XFloatTextField and associated code.
To move the panel up (and prevent the keyboard covering the view) I used my original code below - it is fairly standard stuff - their are several posts in the forum discussing this method.
The problem appears to be about line 9 - it appears pageView.Top is always 0, not the property value for the view I created. However, it does work OK if you use B4XViews. I have tried several modules and they all appear to suffer from the same problem.
Sorry if my description is a bit scratchy, but before I generate some simple code showing an example I was hoping that someone could spot the issue.
Kind regards
Dave Morris
I am in the process of converting some old code to B4X using the new XUI views, in particular B4XFloatTextField.
I am now having problems with the keyboard hiding the views (hopefully it's something simple that I have missed).
I converted a form which used the older textField view to B4XFloatTextField and associated code.
To move the panel up (and prevent the keyboard covering the view) I used my original code below - it is fairly standard stuff - their are several posts in the forum discussing this method.
B4X:
' This method (and the IsFirstResponder() method, below) to ensure the keyboard doesn't cover the relevant
' textfield is taken from here: https://www.b4x.com/android/forum/threads/problem-hide-keyboard.47294/
Private Sub mPage_KeyboardStateChanged(oskHeight As Float)
If oskHeight = 0 Then ' Keyboard has been hidden
mPage.RootPanel.Top = 0
Else ' Keyboard has been shown
For Each pageView As View In mPage.RootPanel.GetAllViewsRecursive
If IsFirstResponder(pageView) Then
Dim viewBottom As Int = pageView.Top + pageView.Height ' This appears to be the problem pageView.Top = 0
Dim keyboardTop As Int = mPage.RootPanel.Height - oskHeight
Dim actualViewBottom As Int = viewBottom + mPage.RootPanel.Top
Dim panelTopModifier As Int = mPage.RootPanel.Top - (oskHeight - (mPage.RootPanel.Height - viewBottom))
If keyboardTop < actualViewBottom Then
mPage.RootPanel.Top = Min(0, panelTopModifier)
End If
Exit
End If
Next
End If
End Sub
' This method (and the mPage_KeyboardStateChanged() method, above) to ensure the keyboard doesn't cover the relevant
' textfield is taken from here: https://www.b4x.com/android/forum/threads/problem-hide-keyboard.47294/.
Private Sub IsFirstResponder(ntvObj As NativeObject) As Boolean
Return ntvObj.RunMethod("isFirstResponder", Null).AsBoolean
End Sub
The problem appears to be about line 9 - it appears pageView.Top is always 0, not the property value for the view I created. However, it does work OK if you use B4XViews. I have tried several modules and they all appear to suffer from the same problem.
Sorry if my description is a bit scratchy, but before I generate some simple code showing an example I was hoping that someone could spot the issue.
Kind regards
Dave Morris