Alternative approach for behaviors, leveraging existing event system

Martin Fox martin at martinfox.com
Fri Oct 20 17:51:01 UTC 2023


John,

>> 
>> You’re proposing using a similar mechanism to enable behaviors to communicate with their controls. That seems like a different problem that deserves a different discussion. In particular I don’t think these two problems need to be solved at the same time even if they both end up using events. The toolkit deficiencies are easier to identify and address than the control/behavior/skin architecture (which seems to be a source of endless debate).
>> 
> Well, I primarily looked at how Behaviors can communicate with Controls, and especially how this was done in Andy's proposal with an indirection (FunctionTag).  The indirection, which acts on an event, looks suspiciously like translating a set of raw keys/gestures into a higher level event (perhaps not application level, but certainly higher level) and there can easily be multiple ways that result in the same function being executed.  Some of these functions are conceivably also of value to trigger directly, perhaps in response to a global hot key.
> 
I’m not sure I entirely follow you. I think we might have different models of what’s going on.

The FunctionTag in Andy’s proposal is a replacement for a Java method. In a perfect world a control would expose a copy() method but currently most do not, the method is buried in the behavior and not visible to external clients. Exposing a COPY FunctionTag with a mechanic for invoking it is a work-around, it’s a route to invoke an operation in the behavior bypassing the control.

Whether the copy operation is exposed to via a method or a FunctionTag invoking it should immediately perform a copy. For that reason I don’t think we should replace FunctionTags with Events. Events are meant to be fired but once you fire an event a lot of machinery gets involved and you can’t guarantee the event will reach the targeted control.

We could still use an event to implement, say, the Copy menu item. Bundle the COPY FunctionTag in a GoDoIt event targeted at the focusOwner and fire it. Let it bubble up until it finds a control that wants to execute it.

Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20231020/cdaeda64/attachment.htm>


More information about the openjfx-dev mailing list