Access to private EventHandlers

José Pereda jose.pereda at gluonhq.com
Thu Dec 17 18:57:26 UTC 2020


While chasing down an issue on Mac with application events, we have noticed
that there is some code under a private package that apparently it is
supposed to be used by developers, which of course it is discouraged:
com.sun.glass.ui.Application:EventHandler [1] is a public static inner
class under a private package, that is added to the Application class for
subclassing.

So far, only QuantumToolkit does subclass it [2] (just for Quit action and
Theme changed events). However the EventHandler class has more methods for
listening to MacOS/iOS application events.

While most of those events happen before the app starts (and it wouldn't
make sense to try to listen to them app-wise), in particular, the
OpenFilesAction event is forwarded [3] when a second EventHandler is set.
Other events like resign/become active actions can be listened to as well.

A developer could provide a subclass of such EventHandler if it were public
API, but so far, that has to be done accessing private API.

At this point, and following on this other thread [4] that discussed a
similar issue with EventHandlerManager, we should start considering the
design of new public API that could provide developers with access to such
events, with considerations to possible platform specifics.

Regards,
Jose


[1]
https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/glass/ui/Application.java#L45
[2]
https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java#L352
[3]
https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/glass/ui/Application.java#L346
[4]
https://mail.openjdk.java.net/pipermail/openjfx-dev/2020-October/027909.html



--


More information about the openjfx-dev mailing list