From a3060ce66d7db72d9afc83d6dbf6e9d4aa883709 Mon Sep 17 00:00:00 2001 From: Jesse Greenberg Date: Thu, 19 Oct 2017 16:37:43 -0600 Subject: [PATCH] use swapVisibility to manage focus, see #104 --- js/lab/view/LabPlayPanel.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/js/lab/view/LabPlayPanel.js b/js/lab/view/LabPlayPanel.js index d40647b1..8e2486cc 100644 --- a/js/lab/view/LabPlayPanel.js +++ b/js/lab/view/LabPlayPanel.js @@ -120,18 +120,18 @@ define( function( require ) { self.setPlayButtonVisible(); // show the play button } ); - // create a separate node to hold the play and pause button - var playPlayPauseButton = new Node(); + // @private - create a separate node to hold the play and pause button + this.playPlayPauseButton = new Node(); // add the play and pause button - playPlayPauseButton.addChild( this.playButton ); - playPlayPauseButton.addChild( this.pauseButton ); + this.playPlayPauseButton.addChild( this.playButton ); + this.playPlayPauseButton.addChild( this.pauseButton ); // create the content of the panel, with the play pause button and the radio buttons var startVBox = new HBox( { spacing: 20, children: [ - playPlayPauseButton, + this.playPlayPauseButton, ballModeRadioButtons ] } ); @@ -155,8 +155,10 @@ define( function( require ) { */ togglePlayPauseButtonVisibility: function() { assert && assert( this.playButton.visible !== this.pauseButton.visible, 'the visibility of the play and pause buttons should alternate' ); - this.playButton.visible = !this.playButton.visible; - this.pauseButton.visible = !this.pauseButton.visible; + + var visibleButton = this.playButton.visible ? this.playButton : this.pauseButton; + var invisibleButton = this.playButton.visible ? this.pauseButton : this.playButton; + this.playPlayPauseButton.swapVisibility( visibleButton, invisibleButton ); }, /**