Skip to content

Commit 536016d

Browse files
committed
Added isShowingProperty to Dialog, see #369
1 parent ee2cb3e commit 536016d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

js/Dialog.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ define( require => {
1515
const AccessibilityUtil = require( 'SCENERY/accessibility/AccessibilityUtil' );
1616
const AccessiblePeer = require( 'SCENERY/accessibility/AccessiblePeer' );
1717
const AlignBox = require( 'SCENERY/nodes/AlignBox' );
18+
const BooleanProperty = require( 'AXON/BooleanProperty' );
1819
const DialogIO = require( 'SUN/DialogIO' );
1920
const Display = require( 'SCENERY/display/Display' );
2021
const FullScreen = require( 'SCENERY/util/FullScreen' );
@@ -147,8 +148,11 @@ define( require => {
147148
// see https://github.com/phetsims/joist/issues/293
148149
assert && assert( this.isModal, 'Non-modal dialogs not currently supported' );
149150

150-
// @protected - whether the dialog is showing
151-
this.isShowing = false;
151+
// @protected (read-only) - whether the dialog is showing
152+
this.isShowingProperty = new BooleanProperty( false, {
153+
tandem: options.tandem.createTandem( 'isShowingProperty' ),
154+
phetioReadOnly: true
155+
} );
152156

153157
// create close button
154158
const closeButton = new CloseButton( {
@@ -302,9 +306,9 @@ define( require => {
302306

303307
// @public
304308
show: function() {
305-
if ( !this.isShowing ) {
309+
if ( !this.isShowingProperty.value ) {
306310
window.phet.joist.sim.showPopup( this, this.isModal );
307-
this.isShowing = true;
311+
this.isShowingProperty.value = true;
308312

309313
// a11y - focus is returned to this element if dialog closed from accessible input
310314
this.activeElement = this.activeElement || Display.focusedNode;
@@ -329,10 +333,10 @@ define( require => {
329333
* @public
330334
*/
331335
hide: function() {
332-
if ( this.isShowing ) {
336+
if ( this.isShowingProperty.value ) {
333337

334338
window.phet.joist.sim.hidePopup( this, this.isModal );
335-
this.isShowing = false;
339+
this.isShowingProperty.value = false;
336340

337341
// a11y - when the dialog is hidden, make all ScreenView content visible to assistive technology
338342
this.sim.setAccessibleViewsVisible( true );

0 commit comments

Comments
 (0)