Android Question [B4X] B4XPages - IME_HeightChanged event problems

agraham

Expert
Licensed User
Longtime User
I'm using B4A and I've implemented the IME handling as described by Erel here and am having different problems with IME_HeightChanged in different projects.

Lets start with the attached Erel's ThreePagesExample with IME_HeightChanged events added in the B4A project. I get a IME_HeightChanged event when I tap on the text field in the login page, but I get another event when I type the first character, so it looks like the IME has closed, but it hasn't! After that I get no more events until the process is closed and restarted.

In a different project the events appear to behave as expected until you change pages with the IME open. Then the IME_HeightChanged event triggered by the closure is raised in the new page and not the old one, so the old one still thinks the IME is open if it is tracking such a thing.
 

Attachments

  • ThreePagesExampleIME.zip
    14.7 KB · Views: 226

agraham

Expert
Licensed User
Longtime User
I can't find the first problem, but in another similar project, derived from the ThreePagesExample, where the events appear to behave as expected (for reasons I don't understand) until you change pages with the IME open. Then the IME_HeightChanged event triggered by the closure is raised in the new page and not the old one, so the old one still thinks the IME is open if it is tracking such a thing.

Putting this in Main activity
B4X:
Public Sub GetIme As IME
    LogColor("GetIme", Colors.Red)
    Return ime
End Sub
And calling this in B4XMainPage when changing pages seems to ensure the event is called in the correct page.
B4X:
Sub btnLogin_Click
    Dim ime As IME = CallSub(Main, "GetIme")
    ime.HideKeyboard
    Sleep(100) ' needs a reasonable delay otherwise event happens on the new page  
    B4XPages.ShowPageAndRemovePreviousPages("Page 2")
End Sub
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I've found the key difference between the project that has the unexpected IME_HeightChanged on pressing a key on the IME and the project that behaves as expected.

The errant project loads its layout into Root
B4X:
    Root.LoadLayout("Login")
The one that works as expected uses a B4XDrawer and crucially loads a layout into the Drawer left panel.
This works
B4X:
    'Root.LoadLayout("Login")
   
    Drawer.Initialize(Me, "Drawer", Root, 200dip)
    Drawer.CenterPanel.LoadLayout("Login")  
    Drawer.LeftPanel.LoadLayout("left")
This doesn't work - I'm baffled as to why. left.bal can be a totally blank layout so it seems the content of it is irrelevant.
B4X:
    'Root.LoadLayout("Login")
   
    Drawer.Initialize(Me, "Drawer", Root, 200dip)
    Drawer.CenterPanel.LoadLayout("Login")  
    'Drawer.LeftPanel.LoadLayout("left")
 
Upvote 0
Top