Hi,

Classes which extends Node have access to the protected method 
`setEventHandler`[1]. It makes it exceptional easy to register a user-defined 
onXXX event handler.

However, for custom EventTarget which do not extend Node, it becomes cumbersome 
as JavaFX expects us to create a whole new EventDispatcher to register custom 
event handlers/filters on these targets. JavaFX already has a number of 
implementation for EventDispatcher in the `com.sun` package. The most basic of 
which are BasicEventDispatcher and EventHandlerManager. The later seems to have 
all the necessary public methods to make it easier to create new EventTargets.

Unless there is a good reason which I am missing, JavaFX should provide a basic 
implementation of EventDispatcher to make it easier for developers to create 
custom EventTarget.

FYR, ControlsFX has 3 classes which implement EventTarget directly:

  1.

AutoCompletionBinding [2]


  2.

GridBase [3]

  3.

SpreadsheetCellBase [4]

Regards,
Abhinay

[1] 
https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/javafx/scene/Node.java#L8776
[2] 
https://github.com/controlsfx/controlsfx/blob/jfx-13/controlsfx/src/main/java/org/controlsfx/control/textfield/AutoCompletionBinding.java
[3] 
https://github.com/controlsfx/controlsfx/blob/jfx-13/controlsfx/src/main/java/org/controlsfx/control/spreadsheet/GridBase.java
[4] 
https://github.com/controlsfx/controlsfx/blob/jfx-13/controlsfx/src/main/java/org/controlsfx/control/spreadsheet/SpreadsheetCellBase.java

Reply via email to