iOS Question Keyboard hides TextView on popup

red30

Active Member
Licensed User
I tried to use the example from the CalcRelativeKeyboardHeight Example and found a strange bug there. If I call the keyboard, then everything moves up (this is how it should be), but now if I move the list up and call the keyboard again (by clicking on the TextView), then the list is accidentally scrolled. Perhaps the video will make it clearer:

CalcRelativeKeyboardHeight is not in xCustomListView, I also looked for solutions on the forum and found that you can do this:
B4X:
Sub Page1_KeyboardStateChanged (Height As Float)  
    Dim p As View = clv.AsView.Parent.Parent
    Dim rel As Int = p.CalcRelativeKeyboardHeight(Height)
    If rel = 0 Then rel = clv.AsView.Height
    clv.sv.Height = Min(rel, clv.AsView.Height)
End Sub
It helps if I call the keyboard at the end of the CLV, but it doesn't make the keyboard stick to the TextView being edited.
How can I use xCustomListView to prevent the keyboard from closing the TextView when called? Also, everything is complicated by the fact that I want the keyboard to be hidden when I start scrolling through the list:
B4X:
Private Sub clv_ScrollChanged (Offset As Int)
    Page1.ResignFocus
End Sub
 

red30

Active Member
Licensed User
I'm not sure that I understand the problem from the video.
I could show more precisely if in ios it was possible to show touches ...
You can check for yourself. On the last TextView, invoke the keyboard. Further, I do not hide the keyboard, scroll up and try again to click on the TextView.
The best way is to avoid resizing the list and instead add a "stub" item at the bottom of the list and scroll the list to make the relevant item visible.
I do not understand what do you mean. I just wanted to make it work like an Android. I used IME library:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
   
    IME.Initialize("IME")
    IME.AddHeightChangedEvent
   
    For i=0 To 15
        clv.Add(CreateOkNotOk("Item "&i),"")
    Next
End Sub

Sub CreateOkNotOk(Text As String) As Panel
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, clv.AsView.Width, Activity.Height*0.20)
    p.LoadLayout("Layout2")
    lblTitle.Text=Text
    tv.Color=Colors.White
    Return p
End Sub

Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
    clv.Base_Resize(100%x,NewHeight-Activity.Height*0)'clv Height = 100%y
End Sub
 
Last edited:
Upvote 0

Alexander Stolte

Expert
Licensed User
I do not understand what do you mean. I just wanted to make it work like an Android. I used IME library:
He means a dummy item that is as big as the keyboard, so you can then see the last entries. You can delete the item as soon as the keyboard is closed.

From my experience I can say, save the current scroll position in a variable before you resize the xCustomLsitView and then resize the list and scroll back to that position that was in the variable.
maybe that helps too:
 
Upvote 0

red30

Active Member
Licensed User
Don't resize CLV. If you resize it the list will be scrolled.
The solution is to change the CLV scroll position instead when the keyboard appears. This solution will also work in Android better.
I do not understand. Can you give an example?
He means a dummy item that is as big as the keyboard, so you can then see the last entries. You can delete the item as soon as the keyboard is closed.

From my experience I can say, save the current scroll position in a variable before you resize the xCustomLsitView and then resize the list and scroll back to that position that was in the variable.
maybe that helps too:
I cannot use scrolling as I need to hide the keyboard when scrolling:
B4X:
Private Sub clv_ScrollChanged (Offset As Int)
    Page1.ResignFocus
End Sub
I just want it to work like an adroid (I used the IME library), except that in ios I need to hide the keyboard when scrolling.
 
Upvote 0

red30

Active Member
Licensed User
I never found a solution to this problem... I still could not get the keyboard to work with CLV the same way as in Android.
Can anyone have any ideas?
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
 
Upvote 0

red30

Active Member
Licensed User
This is a great solution! Thank you!
But I still have a question that the editable field would always be above the keyboard. That is, when the keyboard appears, you need to move the editable field above it. How can i do this?
 
Upvote 0

red30

Active Member
Licensed User
You will need to find the text field position, and scroll the list if needed. This is done with CLV.sv.ScrollViewOffsetY = CLV.sv.ScrollViewOffsetY + offset_needed
Yes, that's what I wanted to do, but I ran into two problems:
1) I could find the current position of the edited text in the BeginEdit event, but I don't know how.
2) CLV.sv.ScrollViewOffsetY the clv_ScrollChanged event is called, and in it I would like to hide the keyboard using "page.ResignFocus"
 
Upvote 0
Top