On Tue, 19 May 2026 15:34:43 GMT, Martin Fox <[email protected]> wrote:

>> This PR alters the way ComboBox and Spinner deliver KeyEvents to their 
>> TextField editors. When a ComboBox or Spinner is the focus owner it is the 
>> target of all key events. Currently the skin installs a filter to catch key 
>> events and re-fire most of them at the TextEdit. The skin copies the event, 
>> fires the copy at the TextField, and then consumes the original event. This 
>> confuses the system menu bar logic on macOS; only the original event can 
>> trigger a menu item and that event is always being consumed.
>> 
>> In this PR only the original key event makes its way up and down the event 
>> dispatch chain. To drive the TextField the skin delivers the event copy 
>> directly to the TextField's event dispatcher and only consumes the original 
>> event if the TextField consumes the copy.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Martin Fox has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Better comments for dispatching utility

These are very good questions!

> if you install a KeyEvent filter on a scene and the user is typing in a 
> ComboBox would you prefer the target of the key event to be the ComboBox or 
> the TextField? 

This is why I don't like the `Event.target` at all.  In my opinion (and I 
understand I am late to the party and the things are unlikely to change) there 
should only be one event, delivered to its target (which, in the case of a 
`KeyEvent`, a current focus owner which is the `TextField`).  If someone adds a 
listener or a filter somewhere in the hierarchy - fine.

There should be no copying of the event objects for the sole purpose of 
changing its target.  That's how it works in AWT and Swing.  FX chose a 
different path of complexity, event clones, ignoring the consumed flag, and 
happy dispatching of already consumed events.  Which means we'll have much fun 
dealing with the consequences.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/2166#issuecomment-4501582606

Reply via email to