[Request for Comments] Behavior / InputMap

Michael Strauß michaelstrau2 at gmail.com
Fri Oct 6 14:13:19 UTC 2023


Hi Andy,

I think the opaqueness of JavaFX controls is one of the greatest
shortcomings of the framework, so I welcome an enhancement.

Some thoughts:

1. It seems that the behavior implementation is still hard-coded into
the skin implementation. For example, TextFieldSkin uses
TextFieldBehavior; it doesn't seem like I can have a TextFieldSkin
that uses my custom behavior. Do you plan on changing that?

2. The InputMap can have a lot of mappings that are set on each
individual control. However, in almost all cases, the input mappings
are semantically equivalent for all instances of a control. Wouldn't
it make sense to associate input mappings with the control class,
instead of the control instance? Aside from more closely conveying the
semantics of a "default mapping", this should also cut down on the
number of object instances we need to keep around. Of course, it
should still be possible to override a default mapping with a
per-instance mapping.

3. Why are FunctionTags defined on the control class, yet they don't
seem to match the functionality offered by the control class? For
example, there's TextInputControl.DELETE_NEXT_WORD, but there's no
corresponding functionality in TextInputControl. The functionality is
actually implemented in TextInputControlBehavior. But if the
implementation is only available in this particular behavior, why is
the FunctionTag defined on the control class?

4. I'm missing a clear delineation between controls and their
behaviors. For example, there's TextInputControl.selectNextWord(), but
no TextInputControl.deleteNextWord(). The latter is implemented in
TextInputControlBehavior. Why is selectNextWord() implemented in the
control, but deleteNextWord() in the behavior? This is just one
example of lots of peculiarities.

5. More generally, we should start by clearly defining concepts. Up
until now, behaviors were just an implementation detail, so this
wasn't necessary. But what is a behavior? What is the relationship
between a control, its skin and behavior? How would a control author
decide what needs to be put into the control class, and what needs to
be put into the behavior class (cf. selectNextWord/deleteNextWord)?



On Sat, Sep 30, 2023 at 1:18 AM Andy Goryachev
<andy.goryachev at oracle.com> wrote:
>
> Dear fellow JavaFX developers:
>
>
>
> For some time now, we’ve been working to identify missing features in JavaFX that hinder application development.  We’ve been working on adding some of the missing features (for which we’ll have a separate announcement), but I feel that engaging wider community is a rather important part of the process.
>
>
>
> I would like to share with you one such missing feature - ability to extend behavior of the existing components (and make the task of creating new components easier) by adding a public InputMap and BehaviorBase.
>
>
>
> Please find the actual proposal here
>
> https://gist.github.com/andy-goryachev-oracle/294d8e4b3094fe16f8d55f6dd8b21c09
>
>
>
> We are very much interested in your feedback.  Thank you in advance.
>
>
>
> -andy
>
>


More information about the openjfx-dev mailing list