0

I have a problem similar to the one raised in Deselect an item on an javafx ListView on click. In James_D's solution and excellent (as usual) explanation he raises the possibility that the solution may not work in the future if the restricted API underlying the solution in the link changes.

The API in question is com.sun.javafx.scene.control.behavior.CellBehaviorBase, which seems to be the entry point into the selection models from user mouse input. James_D relies on that API without referencing it directly (by way of an event filter). The solution should thus be considered as perfectly 'legal'.

Based on my understanding of the 'language contract' a developer should be able to rely on that API remaining stable or at least not change in a way the renders the solution in the link ineffective.

Is this understanding correct?

Naman
  • 27,789
  • 26
  • 218
  • 353
jfr
  • 397
  • 2
  • 17
  • The exact contract for input events would be pretty huge and not really interesting for developers in most cases. (This is probably why it's not documented in that much detail.) James_D's "issue" with his answer is that it relies on `ListView` is useing `MOUSE_PRESSED` and not `MOUSE_CLICKED` or `MOUSE_RELEASED` events. This doesn't really make a difference, until you're trying to consume the event to prevent it from triggering the normal behavior. – fabian Aug 27 '18 at 18:44
  • @Fabian Thanks for your response. James_D's answer caught my eye because I use the same technique (`MOUSE_PRESSED` filter on the cell) to run a test before the event gets delivered to the 'black box' in `CellBehaviorBase` where it is handled in ways that modify the selection model. If the test fails then the event ..IS.. consumed to abort the work flow. So it does matter. – jfr Aug 27 '18 at 19:06
  • @Fabian Just did quick re-read of James_D's code. If the filter condition is met then the event is consumed. The triggering event is itself not critical except that you need to know what it is to configure the filter. FWIW `CellBehaviorBase` has two `MouseEvent` methods. Filtering for `MOUSE_PRESSED` is helpful, but it seems like too much happens inside the 'black box' for `MOUSE_RELEASED` to be of much use. – jfr Aug 27 '18 at 19:25
  • 1
    Jigsaw is unrelated - modularization of the platform is not related of the public API behavior. – user1803551 Aug 27 '18 at 20:57
  • @fabian just to clarify (what you probably meant ;) whether a pressed/clicked/released triggers anything is typically specified in the os-specific UX-guidelines - a UI framework (or toolkit, as fx prefers to think of itself) implements that specification. Straying from that standard behaviour means violating ux-guidelines ... or the other way round: fx might not support the rules of all OSs (f.i. in mobile apps) – kleopatra Aug 28 '18 at 08:57

0 Answers0