Closed jessegreenberg closed 1 year ago
Another issue is that DragListener functionality is generally implemented with start
and end
options, which currently are not called with PressListener's click
. To correctly respond, DragListener needs to override click
and call these functions.
I did this in the above commits. @zepumph could you please review? In https://github.com/phetsims/scenery/commit/4dd8aa3ad49a9109c7578a6124968df56665bd08 I added click support to DragListener by adding an option called allowClick
and overriding click
to support DragListener callbacks. In https://github.com/phetsims/sun/commit/6e99b23a34650ddf7c9152ebd36de3cc332a7d37 I added PDOM to ToggleSwitch and used the new allowClick
option.
Review:
Would PressListener.click()
return false if this.canClick()
was false?
is allowClick
basically just us treating the DragListener like a "pdom-only PressListener"? That feels a bit strange to me, perhaps a name that suggests general pdom support for the DragListener, like overridePDOM:true
(i don't like that). Or maybe just name it to be the same as the function canClick: true
. defaults to false
.
Otherwise looks good! Thanks for taking this on.
Hey, just a ping here, this has been sitting for quite some time.
Would PressListener.click() return false if this.canClick() was false?
Yes. DragListener calls super.click()
, which calls this.canClick()
and click
is overridden in the subtype. So DragListener.click() will correctly return false.
Or maybe just name it to be the same as the function canClick: true. defaults to false.
I like that and will go with that. I also considered allowPDOMClick
so it is clearly about that feature. I think canClick
to match the function and documentation describing the need makes sense.
OK, with the rename that was recommended and the note
Otherwise looks good!
I think this can be closed.
The ToggleSwitch has a requested PDOM representation as
This much is easy enough. But there is an issue with activating the ToggleSwitch because it uses DragListener and click is specifically disabled with that listener at https://github.com/phetsims/scenery/blob/5120fcc377304ca15532e2ee867c24c87448e71a/js/listeners/DragListener.js#L314-L316 because of https://github.com/phetsims/scenery/issues/903. It seems like we could either a) Optionally return false in DragListener.canClick, so that this DragListener and others like it can respond to click. b) Add a new input listener to ToggleSwitch that toggles the Property on click. c) Revisit a different solution to https://github.com/phetsims/scenery/issues/903?
I think I am leaning toward (a) because it is more general and could be helpful in the future. But the desire to use
click
with something that uses DragListener is also very rare, so maybe it isn't worth the option added to DragListener.