Thanks for having a look!

On 30/11/2023 19:47, Andy Goryachev wrote:

I think BehaviorContext looks suspiciously like a (skin) input map, so I would rather see that.

Invention of State class is a way to work around the stateless behavior which, though it adds (in my opinion) very little, might still be a feature that app developers want to exploit - at least in terms of saving on per-instance key maps.  So any alternative proposal should also support a stateless behavior.

I'm unsure what you are trying to say here.

The State class is internal, and can be anything, and take any form.  If you only need to add a single EventHandler, you can also make that a class instead of a Lambda and have the state there. The State class, which can be named anything, is just a convenient way to share state amongst multiple handlers without having to construct each of them with special parameters, or having to put the state in the main class's fields (which would make it not reusable).

I do however see that I did not take reusability of the keymaps into account in this version, that will need to be adjusted -- I was more focused on keeping Behaviors isolated for now, not needing a Control until installed, and having 0 references between Skins and Behaviors.

I was hoping for more comments on how the seperation between Skin and Behavior is done in this PR.  I will attempt to adjust TextInputControl soon (and I will try a few subclasses of ButtonBehavior, to see how they can be built "on top" of another behavior) -- so far I've not found any real problems with this approach.

--John

*From: *openjfx-dev <openjfx-dev-r...@openjdk.org> on behalf of John Hendrikx <john.hendr...@gmail.com>
*Date: *Wednesday, November 29, 2023 at 14:54
*To: *openjfx-dev@openjdk.org <openjfx-dev@openjdk.org>
*Subject: *Behavior API proof of concept PR

For those still interested, I've updated
https://github.com/openjdk/jfx/pull/1265 with a replaced ButtonBehavior
and SpinnerBehavior, using concepts laid out in
https://gist.github.com/hjohn/c7b1bf9d4a4770b1b3ae854b20fbaa94

Any feedback is welcome, I think it's making progress, and the changes
required seem quite doable.

The ability for Behaviors to intercept any event from its Control or its
(named) children makes Behaviors a lot more powerful than earlier
proposals, allowing for completely new interactions without requiring
Skin changes.

--John

Reply via email to