RFR: 8207759: VK_ENTER not consumed by TextField when default Button exists [v3]

John Hendrikx jhendrikx at openjdk.org
Sat Nov 9 11:01:16 UTC 2024


On Sat, 9 Nov 2024 00:49:22 GMT, Martin Fox <mfox at openjdk.org> wrote:

> > I checked the events that are copied, and it is basically making the copy to adjust the source (target remains constant). That's really odd; I'd expect the source to remain the same as well (ie. the Scene or Window, not the "previous" filter/handler Node level), especially as it is documented as:
> 
> I haven't walked through this in AWT (there are only so many hours in the day) but I believe the AWT `source` corresponds to the JavaFX `target` i.e. the object the event was fired against. JavaFX repurposes `source` as the object the handler or filter was registered on. JavaFX shouldn't be pointing at the AWT documentation since it doesn't match the JavaFX implementation.

Well, it implements AWT's `EventObject` through `class Event extends EventObject` -- it would be rather silly to repurpose `getSource` for something else, but then still extend AWT's `EventObject`. 

The class docs of `Event` mention an event source, and describes it as "The event source specifies for an event handler the object on which that handler has been registered and which sent  the event to it" -- that sentence is rather hard to decode, but I guess their meaning is that the Event received by your event handler will have its source set to the object where you registered your handler (ie. a `Node` in most cases) -- it would be similar to `getBean` for properties, but in an far more roundabout way.

And then there's a constructor for `Event` that mentions source being `the event source which sent the event`.

So basically, there are now three definitions of source, two that seem constant, and one that requires an event to be copied before having an event filter or handler receive it...

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

PR Review Comment: https://git.openjdk.org/jfx/pull/15#discussion_r1835339027


More information about the openjfx-dev mailing list