phetsims / sun

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

Opening a modal popup should interrupt other user interactions #700

Closed pixelzoom closed 3 years ago

pixelzoom commented 3 years ago

Opening a modal dialog does not currently interrupt other user interactions. For example, with multitouch, I can be dragging a slider, open a modal dialog, and continue dragging the slider. And it does not seem like this should be the responsibility of the client.

A modal dialog is (by definition) supposed to prevent the user from interacting with the reset of the application until the dialog is closed.

pixelzoom commented 3 years ago

Dialog extends Popupable( Panel ). Popupable calls phet.joist.sim.showPopup. So Sim showPopup is where this should be handled. Probably by calling this.rootNode.interruptSubtreeInput() if isModal.

pixelzoom commented 3 years ago

The first thing I did (in the above commit) was to clean up Sim showPopup and hidePopup. Specifically, I renamed parameter node to popup, and improved the overall documentation.

pixelzoom commented 3 years ago

I added this.rootNode.interruptSubtreeInput in the above commit, and that seems to have the desired effect. I'm not certain, but I probably also could have called this.display.interruptInput.

@jonathanolson please review, feel free to change if there's a better way. Review is high priority and blocks publication, since this is a significant change to Sim.js.

jonathanolson commented 3 years ago

Looks great to me, and looks like the right approach. Thanks!