agraham Expert Licensed User Longtime User Jun 17, 2020 #1 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 ThreePagesExampleIME.zip 14.7 KB · Views: 555
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.
agraham Expert Licensed User Longtime User Jun 17, 2020 #2 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
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
agraham Expert Licensed User Longtime User Jun 17, 2020 #3 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
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")
Erel B4X founder Staff member Licensed User Longtime User Jun 18, 2020 #4 I'm not sure, however you are expected to load a layout to the LeftPanel. So if it works in this case then it should be fine. Upvote 0
I'm not sure, however you are expected to load a layout to the LeftPanel. So if it works in this case then it should be fine.
agraham Expert Licensed User Longtime User Jun 18, 2020 #5 Erel said: So if it works in this case then it should be fine Click to expand... What about the bigger picture, when it appears to not work satifactorily without using a Drawer? Upvote 0
Erel said: So if it works in this case then it should be fine Click to expand... What about the bigger picture, when it appears to not work satifactorily without using a Drawer?
Erel B4X founder Staff member Licensed User Longtime User Jun 18, 2020 #6 The activity attribute was missing in the example: Code: SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden) It is required when handling the height changed event. Do you still see any problem? Upvote 0
The activity attribute was missing in the example: Code: SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden) It is required when handling the height changed event. Do you still see any problem?
agraham Expert Licensed User Longtime User Jun 18, 2020 #7 Erel said: Do you still see any problem? Click to expand... No. That's seems to have fixed it. I spent all yesterday trying to isolate this fearing that I had found a deal-breaker. Thankfully not it seems. Upvote 0
Erel said: Do you still see any problem? Click to expand... No. That's seems to have fixed it. I spent all yesterday trying to isolate this fearing that I had found a deal-breaker. Thankfully not it seems.
Erel B4X founder Staff member Licensed User Longtime User Jun 18, 2020 #8 I also forgot about this attribute. I've added a note about it in the B4XPages thread. Upvote 0
LucaMs Expert Licensed User Longtime User Nov 7, 2024 #9 Erel said: I also forgot about this attribute. I've added a note about it in the B4XPages thread. Click to expand... (I know this is an old thread, but I think it's appropriate to write here this time) Activity does not scroll when ime.ShowKeyboard(SomeEditText) is executed. This also happens in Erel's sample project, after I modified it in such a way that it should do so, i.e. by removing ime.AddHandleActionEvent. Is it possible that this is due to the fact that Views are in the Root? Upvote 0
Erel said: I also forgot about this attribute. I've added a note about it in the B4XPages thread. Click to expand... (I know this is an old thread, but I think it's appropriate to write here this time) Activity does not scroll when ime.ShowKeyboard(SomeEditText) is executed. This also happens in Erel's sample project, after I modified it in such a way that it should do so, i.e. by removing ime.AddHandleActionEvent. Is it possible that this is due to the fact that Views are in the Root?
LucaMs Expert Licensed User Longtime User Nov 7, 2024 #10 LucaMs said: (I know this is an old thread, but I think it's appropriate to write here this time) Activity does not scroll when ime.ShowKeyboard(SomeEditText) is executed. This also happens in Erel's sample project, after I modified it in such a way that it should do so, i.e. by removing ime.AddHandleActionEvent. Is it possible that this is due to the fact that Views are in the Root? Click to expand... I "shortened" the Root and added an EditText programmatically. When it receives focus, I set ime.Show(ThatEditText) and still the Activity scrolling does not happen. In the manifest there is the required line. (For now I can't publish the project, because although it is a test, it partly has the layout of another B4X member. However, it has nothing special.) Upvote 0
LucaMs said: (I know this is an old thread, but I think it's appropriate to write here this time) Activity does not scroll when ime.ShowKeyboard(SomeEditText) is executed. This also happens in Erel's sample project, after I modified it in such a way that it should do so, i.e. by removing ime.AddHandleActionEvent. Is it possible that this is due to the fact that Views are in the Root? Click to expand... I "shortened" the Root and added an EditText programmatically. When it receives focus, I set ime.Show(ThatEditText) and still the Activity scrolling does not happen. In the manifest there is the required line. (For now I can't publish the project, because although it is a test, it partly has the layout of another B4X member. However, it has nothing special.)
LucaMs Expert Licensed User Longtime User Nov 7, 2024 #11 I opened a new thread and attached a test project. Upvote 0