iOS Question [SOLVED] B4XPages / ScrollView / How to bring back ScrollView in original position?

christianjeannot

Member
Licensed User
Hello Community,

In my App I have several text fields on a scroll view. I found out how to hide the keyboard overlapping a text field.
What is the best way to have the original position before entering text?

I searched the documentation and found no answer.
I searched the forum and found several threads about scrollviews and position issues / handling. I take a look on some threads but I was not able to adjust this to my App.

I have attached a small example project.

Best regards

--Christian
 

Attachments

  • Upload_Helper_ScrollView.zip
    5.8 KB · Views: 223

Alexander Stolte

Expert
Licensed User
Longtime User
What is the best way to have the original position before entering text?
B4X:
'add this to Class_Globals
Private offset_before_keyboard As Float = 0

Private Sub B4XPage_KeyboardStateChanged(Height As Float)
    If Height > 0 Then
        offset_before_keyboard = svTest.ScrollOffsetY 'fill this variable here with the current offset
        svTest.ScrollTo(0, svTest.ScrollOffsetY + Height, False)
        'NewHight = svTest.ScrollOffsetY + Height
    End If
End Sub

'scroll to this offset
Private Sub txtEntry1_EnterPressed
    txtEntry1.RequestFocus
    B4XPages.GetNativeParent(Me).ResignFocus
    svTest.ScrollTo(0, offset_before_keyboard, False)'scroll to the offset
End Sub
 

Attachments

  • Upload_Helper_ScrollView.zip
    6.1 KB · Views: 218
Upvote 0
Top