Skip to content

Commit

Permalink
interrupt when disabled by default on all Nodes, #1112
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Nov 6, 2020
1 parent a316047 commit 05fcd4c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/nodes/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ function Node( options ) {

// @public {TinyForwardingProperty.<boolean>} - See setEnabled() and setEnabledProperty()
this._enabledProperty = new TinyForwardingProperty( DEFAULT_OPTIONS.enabled, DEFAULT_OPTIONS.enabledPropertyPhetioInstrumented );
this._enabledProperty.lazyLink( this.onEnabledPropertyChange.bind( this ) );

// @public {TinyProperty.<boolean>} - Whether input event listeners on this Node or descendants on a trail will have
// input listeners. triggered. Note that this does NOT effect picking, and only prevents some listeners from being
Expand Down Expand Up @@ -3564,6 +3565,16 @@ inherit( PhetioObject, Node, {
},
get enabled() { return this.isEnabled(); },

/**
* Called when enabledProperty changes values.
* @protected - override this to change the behavior of enabled
*
* @param {boolean} enabled
*/
onEnabledPropertyChange: function( enabled ) {
!enabled && this.interruptSubtreeInput();
},

/**
* Sets whether input is enabled for this Node and its subtree. If false, input event listeners will not be fired
* on this Node or its descendants in the picked Trail. This does NOT effect picking (what Trail/nodes are under
Expand Down

0 comments on commit 05fcd4c

Please sign in to comment.