iOS Question problem hide keyboard

fifiddu70

Well-Known Member
Licensed User
hi, I have several texview on my program , some are located in the upper delloo screen while others are located at the bottom. My problem comes when I write such a TextView up and then I would write in a TextView down, I can not see it because of the keyboard visible , how do I prevent the keyboard hide me the texview located under the keyboard not allowing me to write to them ?
 
Last edited:

stevel05

Expert
Licensed User
This should move the Root panel enough so the focused view is visible. The next question is how to move from one text field to the next. A quick search seems to imply that it is up to the programmer to manage that, unless anyone has found a solution already. I have run out of time today, if you don't get a solution, I may be able to have a look tomorrow.

B4X:
Sub Page1_KeyboardStateChanged (Height As Float)
    If Height = 0 Then
        Page1.RootPanel.Top = 0
    Else
        For Each V As View In Page1.RootPanel.GetAllViewsRecursive
               If IsFirstResponder(V) Then Page1.RootPanel.Top = Min(0,Page1.RootPanel.Top - (Height - (Page1.RootPanel.Height - (V.Top + V.Height))))
        Next
    End If
End Sub
Sub IsFirstResponder(V As NativeObject) As Boolean
    If V.RunMethod("isFirstResponder",Null) = 1 Then Return True
    Return False
End Sub
 

fifiddu70

Well-Known Member
Licensed User
my probem is: hide the keyboard when i touch the screen and show when i touch a texview.
 

stevel05

Expert
Licensed User
Add textview.resignfocus to a finishededit event. (may not be called exactly that, but I'm not at my computer at the moment)
 

fifiddu70

Well-Known Member
Licensed User
resolved, i use page.resignfocus for hide keyboard, i make a button and this button i have write: page1.resignfocus.
 

Hilton

Active Member
Licensed User
resolved, i use page.resignfocus for hide keyboard, i make a button and this button i have write: page1.resignfocus.
I am tending to build my screens on a scrollview so that it is easy for the user to see what they want with the keyboard up. The problem I found was that when the keyboard is up, the toolbar is hidden. After fiddling around and reading the various suggestions, I discovered that in the click event of a page or scrollview I choose any existing text field (no added buttons etc) and:
B4X:
Sub svContFields_click
    edtName.RequestFocus
    edtName.ResignFocus
End Sub
I found that to resignfocus only did not work. So in my case, all the user has to do is tap the screen to get rid of the keyboard.

Bye,
Hilton.
 

tufanv

Expert
Licensed User
This should move the Root panel enough so the focused view is visible. The next question is how to move from one text field to the next. A quick search seems to imply that it is up to the programmer to manage that, unless anyone has found a solution already. I have run out of time today, if you don't get a solution, I may be able to have a look tomorrow.

B4X:
Sub Page1_KeyboardStateChanged (Height As Float)
    If Height = 0 Then
        Page1.RootPanel.Top = 0
    Else
        For Each V As View In Page1.RootPanel.GetAllViewsRecursive
               If IsFirstResponder(V) Then Page1.RootPanel.Top = Min(0,Page1.RootPanel.Top - (Height - (Page1.RootPanel.Height - (V.Top + V.Height))))
        Next
    End If
End Sub
Sub IsFirstResponder(V As NativeObject) As Boolean
    If V.RunMethod("isFirstResponder",Null) = 1 Then Return True
    Return False
End Sub
This code is giving type do not match now but it was working perfect some time ago. Is there nay way to fix it ?
( it givs the error on :
If V.RunMethod("isFirstResponder",Null) = 1ThenReturnTrue )
 

stevel05

Expert
Licensed User
What do you get if you log the value?

B4X:
Log( V.RunMethod("isFirstResponder",Null))
 

stanmiller

Active Member
Licensed User
This code is giving type do not match now but it was working perfect some time ago. Is there nay way to fix it ?
( it givs the error on :
If V.RunMethod("isFirstResponder",Null) = 1ThenReturnTrue )
Add .AsBoolean like so.

If V.RunMethod("isFirstResponder",Null).AsBoolean = True Then
Return True
End If

That should banish the warning.
 

icefairy333

Active Member
Licensed User
this code will be better ^_^
B4X:
Sub pg_KeyboardStateChanged (Height As Float)
    '输入法不挡住输入框
    If Height = 0 Then
        pg.RootPanel.Top = 0
    Else
        For Each V As View In pg.RootPanel.GetAllViewsRecursive
            If IsFirstResponder(V) Then pg.RootPanel.Top = Min(0,0 - (Height - (pg.RootPanel.Height - (V.Top + V.Height+50dip))))
        Next
    End If
End Sub
'判断是否为第一响应者
Sub IsFirstResponder(V As NativeObject) As Boolean
    Return V.RunMethod("isFirstResponder",Null).AsBoolean
End Sub
This should move the Root panel enough so the focused view is visible. The next question is how to move from one text field to the next. A quick search seems to imply that it is up to the programmer to manage that, unless anyone has found a solution already. I have run out of time today, if you don't get a solution, I may be able to have a look tomorrow.

B4X:
Sub Page1_KeyboardStateChanged (Height As Float)
    If Height = 0 Then
        Page1.RootPanel.Top = 0
    Else
        For Each V As View In Page1.RootPanel.GetAllViewsRecursive
               If IsFirstResponder(V) Then Page1.RootPanel.Top = Min(0,Page1.RootPanel.Top - (Height - (Page1.RootPanel.Height - (V.Top + V.Height))))
        Next
    End If
End Sub
Sub IsFirstResponder(V As NativeObject) As Boolean
    If V.RunMethod("isFirstResponder",Null) = 1 Then Return True
    Return False
End Sub
 
Last edited:
Top