[Request for Comments] Behavior / InputMap
Andy Goryachev
andy.goryachev at oracle.com
Mon Oct 9 18:38:46 UTC 2023
Thank you for the feedback!
You are right: even though Skins are public classes now, they are very difficult to extend – at least, much more difficult that Swing UIs. It’s a source of constant discussions within the team – how much of it should be made public (protected) to allow for extension vs. how much of it should be hidden as implementation detail to minimize the API surface and allow for evolution. While opening it all up might alleviate developers’ pain when extending, it poses a great(er) danger of introducing of all sorts of compatibility issues with respect to bug fixes and other changes.
If we speak about extending skins specifically, a good question might be: what exactly is missing? Which APIs do we need to enable easier extension of skins?
One thing I would like to clarify is that the Behavior / InputMap proposal is not about extending skins. It is also not about making the concrete behaviors public (a task which is probably as large as adding missing public APIs to skins).
The main goal is to allow for extending and slightly modifying the behavior – like altering the way navigation works in a text control, or adding a new key binding. As a result, the overall proposal is smaller than it could be.
Having said that, nothing prevents us from exploring options to open up skins, or making behaviors public.
To summarize:
* What are the missing APIs in Skins that we can add to simplify extension of skins?
* Would this proposal (BehaviorBase + InputMap) prevent us from moving forward?
What do you think?
-andy
From: openjfx-dev <openjfx-dev-retn at openjdk.org> on behalf of Pedro Duque Vieira <pedro.duquevieira at gmail.com>
Date: Saturday, October 7, 2023 at 14:05
To: openjfx-dev at openjdk.org <openjfx-dev at openjdk.org>
Subject: Re: [Request for Comments] Behavior / InputMap
I second the opinions of others that JavaFX is too closed which, I think, hinders the work of library and app developers.
I wonder if the reasons that were used to make this design decision back when JavaFX was being created still hold true. Back in the beginning there were more developers involved in developing JavaFX, significant features were added at a fast pace so the fact that it was closed wasn't such a big drawback as things were changing quickly and missing features that were spotted could be added relatively quick.
Commenting more specifically on your question... I think Skins could benefit generally from being easier to extend. The promise of skins is that you could easily replace a control behavior and visuals without changing its model (the model being the part of the control that developers usually interact with) but the problem is that the JavaFX SDK control's skins are very difficult to extend. Say, if you only want to add a specific visual feature (something that CSS can't do) it takes a significant effort.
What you usually see is that developers opt to create completely new controls rather than just new skins.
My attempt at providing new skins for existing javafx sdk controls is here: https://github.com/dukke/FXSkins
Still it required quite a bit of effort.. at least more than it could ideally take (I think).
The advantage of this kind of approach (providing new Skins) and the library I created "FXSkins" is that you can enhance the controls of your existing app very easily by setting new skins in the CSS stylesheet. You won't need to change anything directly in the code.
Regarding the current state of the JavaFX SDK Skins, there isn't a clear MVC separation, the skin does the Controller and View part at the same time. Perhaps ideally there would be a clear View part that could easily be extended to add different advanced visuals to the control (by advanced I mean, anything that can't be done with CSS). And then perhaps also the Behavior part where you can easily change the control's functionality. I remember at some point Richard Bair saying that it was a goal to make Behaviors public.
Thanks!
--
Pedro Duque Vieira - https://www.pixelduke.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20231009/39db8b09/attachment.htm>
More information about the openjfx-dev
mailing list