[External] : Re: [Request for Comments] Behavior / InputMap
Andy Goryachev
andy.goryachev at oracle.com
Wed Oct 11 22:36:02 UTC 2023
Martin:
Right, the user-specific mappings are simply not possible in the current version of FX.
Speaking of the platform nuances – this might be relevant to the ongoing platform API discussion. Right now FX picks up nothing from the preferences set by the user within the OS. You are right, macOS allows the user to change key modifiers (for example, switch control and command keys, Settings -> Keyboard -> Keyboard Shortcuts -> Modifier Keys) and FX remains oblivious to this change.
Should FX pick up this user setting? Should it propagate to FX and Swing shortcut keys? Should FX pick up custom colors? And so on...
Getting back to the input map proposal, it followed a JEP format convention, but one thing it isn’t is the requirements document. I wouldn’t mind creating one or adding a section to the proposal, but I wanted to hear the community feedback first (and got plenty, thanks!). Let’s see what else we could find.
Thank you
-andy
From: Martin Fox <martin at martinfox.com>
Date: Wednesday, October 11, 2023 at 14:53
To: Andy Goryachev <andy.goryachev at oracle.com>
Cc: John Hendrikx <john.hendrikx at gmail.com>, openjfx-dev at openjdk.org <openjfx-dev at openjdk.org>
Subject: [External] : Re: [Request for Comments] Behavior / InputMap
Andy,
This might be just a matter of style but IMHO the limitations of the current design aren’t listed in the Summary. For example, I have to get down to the description section before I see this requirement:
ensure that user-defined mappings overwrite default ones and survive a skin change
There’s nothing indicating that this is currently not working (or why it’s not working). But perhaps this is something I should already know since I do spend most of my time down in the platform code.
Perhaps you could start a new thread listing some (all?) examples? I don’t think we have any existing documentation of the key bindings, so here we go:
https://github.com/andy-goryachev-oracle/jfx/tree/8314906.behavior.test/doc-files/behavior<https://urldefense.com/v3/__https:/github.com/andy-goryachev-oracle/jfx/tree/8314906.behavior.test/doc-files/behavior__;!!ACWV5N9M2RV99hQ!J5aVk_bfhcHHNKk1DgQJKJIqb6A81qaEorABC9Gw_eN2gt37o7mnyHlXxI31z_KzDh_mBZGjJNTGqlC7LBjYTg$>
That’s a long list with several platform-specific nuances. You’ll need to re-implement a big chunk of them for the table and tree view controls. In your proposal you give an example of a RichTextArea and it will also need to re-implement all of these.
In macOS 10.14 Apple created the NSStandardKeyBindingResponding<https://urldefense.com/v3/__https:/developer.apple.com/documentation/appkit/nsstandardkeybindingresponding?language=objc__;!!ACWV5N9M2RV99hQ!J5aVk_bfhcHHNKk1DgQJKJIqb6A81qaEorABC9Gw_eN2gt37o7mnyHlXxI31z_KzDh_mBZGjJNTGqlCp23BvQA$> protocol to encapsulate some of the potential binding targets. It’s overkill and doesn’t cover a bunch of common bindings like Shortcut+C for Copy. BTW, there’s a way for power-users to alter these bindings but it relies on them being global.
I’ll dig into the proposal a bit more but probably not before next week.
Martin
From: openjfx-dev <openjfx-dev-retn at openjdk.org> on behalf of Martin Fox <martin at martinfox.com>
Date: Wednesday, October 11, 2023 at 10:27
To: John Hendrikx <john.hendrikx at gmail.com>
Cc: openjfx-dev at openjdk.org <openjfx-dev at openjdk.org>
Subject: Re: [Request for Comments] Behavior / InputMap
On Oct 11, 2023, at 1:03 AM, John Hendrikx <john.hendrikx at gmail.com> wrote:
After reading John's message I realize that the InputMap proposal doesn’t list the limitations of the current design. It seems to be addressing some of the sequencing issues John mentions but doesn’t state outright that it’s doing so or why. I would set aside the proposal and focus on writing a problem statement document first.
A system to remap keys can then be left squarely in the realm of user space, and much nicer solutions can be build by users than whatever JavaFX will provide out of the box.
Seconded. Whatever Eclipse is doing to implement their key binding interface is deep and complex and there’s no way JavaFX could craft a solution Eclipse would use. I think that will be true for most apps that allow user customizable key bindings. And I’m pretty sure that when the user customizes a key binding Eclipse is not tracking down all of the affected controls and updating their per-instance key binding maps. Those maps have to be centralized and shared in some manner.
So in short, what I think this should be about is:
- Ensure user event handlers have priority over behavior/inputmap added ones
- Ensure all behavior actions are available as methods on controls
I have another recommendation (which may be more of a feature request). There should be a centralized way of mapping common keys to actions to ensure a consistent vocabulary across the user interface. As an example, on many controls Shift + up arrow should map to something like “moveUpAndExtendTheSelection”. There are a lot of these standardized bindings, some of them are platform specific, and it’s a really tall order to expect all of the individual control classes to get this right.
On macOS there are two primary means of mapping a key event to an action and both are global. This means most of these mappings happen outside the individual controls and that the mappings are consistent across controls. This also addresses part of what John mentioned above; to make this work controls have to make their actions visible through callable methods.
Phrased as problem statement: currently individual control classes need to separately implement a large set of standardized keyboard bindings. This is a maintenance and testing issue.
- Ensure that if a key is handled by the control, that it is ONLY consumed when it actually triggers an action (navigation keys get consumed regardless, even if no focus change results, that's wrong).
As I recall this is an issue with the traversal engine which is a maybe a separate topic (?) Was a bug ever entered on this?
Martin
On 10/10/2023 19:54, Andy Goryachev wrote:
Re-sending with a smaller image (256kb limit, really?).
From: Andy Goryachev <andy.goryachev at oracle.com><mailto:andy.goryachev at oracle.com>
Date: Tuesday, October 10, 2023 at 10:49
To: Michael Strauß <michaelstrau2 at gmail.com><mailto:michaelstrau2 at gmail.com>
Cc: openjfx-dev at openjdk.org<mailto:openjfx-dev at openjdk.org> <openjfx-dev at openjdk.org><mailto:openjfx-dev at openjdk.org>
Subject: Re: [Request for Comments] Behavior / InputMap
Dear Michael:
Here is a use case for (re-)mapping by the user at runtime:
<image002.jpg>
(key mappings UI in Eclipse).
I can think of several other cases (mentioned in the proposal, I think) so I think we can put the concept of immutable or global InputMap to rest.
Whether the InputMap contains the reference to its control or not is a minor implementation detail, I think.
-andy
From: openjfx-dev <openjfx-dev-retn at openjdk.org><mailto:openjfx-dev-retn at openjdk.org> on behalf of Michael Strauß <michaelstrau2 at gmail.com><mailto:michaelstrau2 at gmail.com>
Date: Tuesday, October 10, 2023 at 10:36
To:
Cc: openjfx-dev at openjdk.org<mailto:openjfx-dev at openjdk.org> <openjfx-dev at openjdk.org><mailto:openjfx-dev at openjdk.org>
Subject: Re: [Request for Comments] Behavior / InputMap
> Yes, one of the features the new design provides is ability to modify key mappings by the user at runtime. So yes, not only it needs to be mutable, but it also adds some APIs for exactly that.
>
I struggle to see a use case for this feature. I can imagine that
there might be some use cases that call for customized input mappings,
but why would this translate to a _mutable_ input map? That's quite a
departure from the way other parts of JavaFX work.
For example, skins are also immutable. If you want to have a different
skin for a control, you don't somehow modify the existing skin
instance; instead, you'd create a new skin class (or -- somehow --
extend an existing skin class), and then install that new skin on your
control.
An input map shouldn't bind input events directly to instance methods
of a particular control instance. It should define the mapping of
events to methods symbolically:
Instead of mapping Event => instance.method(), it should map Event =>
Control::method. The input map could then be stateless and immutable,
and can be set on any control instance. If you want to change the
mappings, just set a different input map instance. There's no need
that an input map would retain a reference to any particular control,
since the control reference can be passed into the input map just as
easily.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20231011/b8d64166/attachment-0001.htm>
More information about the openjfx-dev
mailing list