phetsims / sun

User-interface components for PhET simulations, built on top of Scenery.
MIT License
4 stars 12 forks source link

Add capability for interruption listeners before main listeners in buttons #858

Closed jbphet closed 9 months ago

jbphet commented 10 months ago

There have lately been a number of CT issues that were caused by multitouch situations where a Node is being dragged and a separate multitouch pointer presses a button and subsequently causes changes to the sim's underlying state, then the drag from the first pointer ends and things break. This could potentially be prevented through the use of a pointer interrupt that occurs before any of the button's other listener logic fires.

Examples of issues caused by this problem:

jbphet commented 9 months ago

@jonathanolson and I worked on this several days ago and added a way to interrupt all pointers when a button was pressed. We added this capability to PushButtonModel. I reverted the workaround-ish fixes in fractions-common and build-a-molecule, but noticed that some of the CT errors returned. After some investigation I recognized that the problems in the fractions-related code seemed to be related to the fire-on-hold feature, and that fire-on-hold was no longer working in the Fractions Suite sims. @jonathanolson and I worked on this again today and refined the pointer interrupt capability such that it interrupted all pointers except the one that had led to the current firing of the button's listener. This seemed to work well when testing locally, so the code was committed and I'll keep an eye on CT.

If these changes fix the CT problems we will likely need to add this pointer-interrupt functionality to at least some of the other button model classes.

jbphet commented 9 months ago

The interrupt capability has been added and CT has improved considerably. It seems like there were still some issues that could have been related, but @jonathanolson and I decided it wasn't worth the effort to track these all down, so we added some simple guard code to prevent the problems.

I think the spirit of this has been fulfilled and the buttons are behaving better, so I'm closing.