That may be the clue! HandleEvents is using the Umbrella JS handle() wrapper and that one does automatically e.preventDefault() in their code. Looks like your AddEventListener solution if the way to go for you. HandleEvents is probably useful if you are not really wrapping some existing lib, but writing one from scratch.
You need to redirect it to the CallBack class and the method is called mEventName & "_keypress". If you use Me, then the events are redirected to this class and expect a method here.
Sub myTextBox_KeyPress(event as BANanoEvent) ' where mytextBox is the mEventName (comes from the Abstract Designer layout)
...
End Sub
If you want to handle them in the class itself e.g. to immediately pass the keyCode instead of the whole event, or to cancel it if for example enter is not allowed, you would do:
B4X:
#Event: KeyPress (keyCode as String)
mElement.HandleEvents("keypress", Me, "HandleKeypress")
...
Sub HandleKeypress(event as BANanoEvent)
BANano.CallSub(mCallBack, mEventName & "_keypress", Array(event.keyCode))
end Sub
Can you show me some code and what framework you are trying to wrap? (some runnable code would be great!)
Maybe the object itself has some special internal way to handle these events, and by activating them in your code, you are somehow overwriting their handling.
Maybe the object itself has some special internal way to handle these events, and by activating them in your code, you are somehow overwriting their handling.
That may be the clue! HandleEvents is using the Umbrella JS handle() wrapper and that one does automatically e.preventDefault() in their code. Looks like your AddEventListener solution if the way to go for you. HandleEvents is probably useful if you are not really wrapping some existing lib, but writing one from scratch.