Android Question [Resolved] IME how can I intercept keyboard events

ivanomonti

Expert
Licensed User
Longtime User
B4X:
ime.Initialize("IME")

B4X:
Private Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
    Log(NewHeight)
    Log(OldHeight)
End Sub

Private Sub IME_HandleAction As Boolean

    Dim e As EditText
    e = Sender
   
    If e.Text.Length = 0 Then
        Return True
    Else
        Return False 'will close the keyboard
    End If

End Sub


how can i intercept the closing of the keyboard?

also given the name of the event as examples found in the forum the events do not fire
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Did you add this line to the Manifest file?
B4X:
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)

And these to your project?
B4X:
    IME.Initialize("IME")

    IME.AddHeightChangedEvent

    IME.AddHandleActionEvent(YourEditTextHere)
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
Hai aggiunto questa riga al file manifest?
[CODICE=b4x]
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)
[/CODICE]

E questi al tuo progetto?
[CODICE=b4x]
IME.Initialize("IME")

IME.AddHeightChangedEvent

IME.AddHandleActionEvent(YourEditTextHere)
[/CODICE]
NO, thank 10000
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
Did you add this line to the Manifest file?
B4X:
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)

And these to your project?
B4X:
    IME.Initialize("IME")

    IME.AddHeightChangedEvent

    IME.AddHandleActionEvent(YourEditTextHere)
it doesn't work the same :-(
 
Upvote 0

FrankDev

Active Member
Licensed User
Longtime User
like this ?

Sub ime_HeightChanged ToastMessageShow("jetzt",True) End Sub:
Sub ime_HeightChanged
    
    ToastMessageShow("now",True)
    
End Sub
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
I also need to intercept the pressed key but even following the erl example found in the post I can't succeed, do you have something for this problem too?


B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then
        Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
    End If
    B4XPages.GetManager.RaiseEvent(B4XPages.GetManager.GetTopPage, "B4XPage_KeyPress", Array(KeyCode))
    Return False
End Sub

' it doesn't intercept the code, maybe it's the samsung keyboard, I don't know

B4X:
Sub B4XPage_KeyPress(KeyCode As Int) As Boolean

    Log(KeyCode)

End Sub
 
Last edited:
Upvote 0
Top