phetsims / wave-interference

"Wave Interference" is an educational simulation in HTML5, by PhET Interactive Simulations.
MIT License
19 stars 5 forks source link

Grabbed tool should pop to the front #450

Open samreid opened 5 years ago

samreid commented 5 years ago

From https://github.com/phetsims/wave-interference/issues/434

When grabbing a tool, it should go to the front (in z-ordering) relative to other grabbable tools. This will not be fixed for 2.0.

samreid commented 4 years ago

Measuring tape now moves to the front in the mentioned issue.

samreid commented 4 years ago

Implemented and would be nice to have some QA testing for this feature.

brooklynlash commented 4 years ago

Works in dev.24

KatieWoe commented 3 years ago

I noticed in 1.1.0 rc.3 that this works in most cases, but if the stopwatch is behind another tool, and you press one of its buttons, it does not jump to the top. It does if you grab a non-button area. moveforwardbuttons

samreid commented 3 years ago

There is a natural place we could add a moveToFront listener in the restart button. But the play pause button is a BooleanRectangularToggleButton and has no apparent places to listen for press. We could listen to the play/pause property and move to front when it changes, but then it would also move to front when it changes without a button press. @jonathanolson and @pixelzoom I noticed you have commits in StopwatchNode, can you please recommend how to proceed?

jonathanolson commented 3 years ago

What is the desired behavior? I'm still very uneasy about having a default "moveToFront" inside a component (but I guess you can always wrap it with a Node if desired?)

But the play pause button is a BooleanRectangularToggleButton and has no apparent places to listen for press.

That seems like something that might be nice to have for this and other reasons.

I think the better approach is to NOT have moveToFront baked into StopwatchNode (especially just in the dragTarget!!!), but instead a client can add a listener to it that moves it to the front when interacted with.

samreid commented 3 years ago

I discussed with @arouinfar and we agreed that it's not a blocking publication issue that clicking the buttons doesn't bring the stopwatch to the front. Since waves intro 1.1.0-rc.3 moves the stopwatch node to front for all except for the buttons, I'll remove this issue from the milestone.

I think the better approach is to NOT have moveToFront baked into StopwatchNode (especially just in the dragTarget!!!), but instead a client can add a listener to it that moves it to the front when interacted with.

That seems like a nontrivial issue which would probably need to be discussed with the dev team, and may go against parts of the decision in https://github.com/phetsims/scenery-phet/issues/608#issuecomment-663190147. Up to @jonathanolson if we should open an issue for that.

jonathanolson commented 3 years ago

Or, presumably we'd want all StopwatchNodes to moveToFront with the buttons, so StopwatchNode could create a listener on ALL of itself?

samreid commented 3 years ago

This patch seems to be working OK, is it what you had in mind?

Index: js/StopwatchNode.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/StopwatchNode.js b/js/StopwatchNode.js
--- a/js/StopwatchNode.js   (revision 18007999e489b1f4709ac13fb18695329d80b9d4)
+++ b/js/StopwatchNode.js   (date 1611963761694)
@@ -159,7 +159,7 @@
     const stopwatchVisibleListener = visible => {
       this.visible = visible;
       if ( visible ) {
-        this.moveToFront();
+        // this.moveToFront();
       }
       else {

@@ -205,7 +205,7 @@
       // The StopwatchNode always calls moveToFront on drag start
       const startOption = dragListenerOptions.start;
       dragListenerOptions.start = () => {
-        this.moveToFront();
+        // this.moveToFront();
         startOption && startOption();
       };

@@ -238,6 +238,10 @@
     // @private
     this.numberDisplay = numberDisplay;

+    this.addInputListener( {
+      down: () => this.moveToFront()
+    } );
+
     // support for binder documentation, stripped out in builds and only runs when ?binder is specified
     assert && phet.chipper.queryParameters.binder && InstanceRegistry.registerDataURL( 'scenery-phet', 'StopwatchNode', this );
   }
@@ -293,7 +297,7 @@
    * @param {Object} [options]
    * @returns {function(time:number):string} - see NumberDisplay options.numberFormatter
    */
-  static createRichTextNumberFormatter( options ){
+  static createRichTextNumberFormatter( options ) {

     options = merge( {
samreid commented 3 years ago

I noticed the patch doesn't pop it to the front when dragging out of the toolbox though.

jonathanolson commented 3 years ago

I noticed the patch doesn't pop it to the front when dragging out of the toolbox though.

Presumably we'd want to handle touch-snag and the toolbox pattern! Having a DragListener with attach:false would handle the first, however the second would almost require information from the actual DragListener being triggered, right?

samreid commented 3 years ago

I'll move the latter part of the conversation to a new issue in scenery-phet.

samreid commented 3 years ago

Since this issue is non-blocking for Waves Intro, I'm unassigning. We can continue in https://github.com/phetsims/scenery-phet/issues/659 as appropriate