B4J Question Is it possible to disable key listeners, and how ?

Magma

Expert
Licensed User
Longtime User
Hi there...

well I am pretty sure that already someone asked (may be was me) how is possible to disable a key listener like this:

B4X:
Sub AddKeyPressedListener
    Dim r As Reflector
    r.Target = B4XPages.GetNativeParent(Me).RootPane
    r.AddEventFilter("KeyPressed", "javafx.scene.input.KeyEvent.ANY")
End Sub

but I can't find the solution....

Any help will be SUPER !...
 

William Lancee

Well-Known Member
Licensed User
Longtime User
How about doing nothing in the "KeyPressed_Event"?

Or (untested):

B4X:
r.RemoveEventFilter("KeyPressed", "javafx.scene.input.KeyEvent.ANY")
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
How about doing nothing in the "KeyPressed_Event"?
hmmm... ....??? ...let me see... no I need it :)

B4X:
r.RemoveEventFilter("KeyPressed", "javafx.scene.input.KeyEvent.ANY")
...no RemoveEventFilter at B4J ????

see the "picture"...
1656611352763.png
 
Upvote 0

roerGarcia

Active Member
Licensed User
Longtime User
When you no longer want an event filter to process events for a node or for an event type, remove the filter using the removeEventFilter() method. This method takes the event type and the filter as arguments. In Example 3-2, the filter defined in Example 3-1 is removed from the MouseEvent.MOUSE_PRESSED event for myNode1. The filter is still executed by myNode2 and by myNode1 for the KeyEvent.KEY_PRESSED event.

Example 3-2 Remove a Filter
// Remove an event filter
myNode1.removeEventFilter(MouseEvent.MOUSE_PRESSED, filter);

From https://docs.oracle.com/javafx/2/events/filters.htm
 
Upvote 0
Top