From d2b3ccb1ce28846bc4be122ac54e6cb062245942 Mon Sep 17 00:00:00 2001 From: zepumph Date: Fri, 6 Nov 2020 14:10:26 -0900 Subject: [PATCH] allow SunConstants.componentEnabledListener to be overridden by options in each sun component, https://github.com/phetsims/scenery/issues/1112 --- js/NumberPicker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/NumberPicker.js b/js/NumberPicker.js index fe0d4405..229a8209 100644 --- a/js/NumberPicker.js +++ b/js/NumberPicker.js @@ -80,6 +80,9 @@ class NumberPicker extends Node { arrowLineWidth: 0.25, valueMaxWidth: null, // {number|null} - If non-null, it will cap the value's maxWidth to this value + // {function(boolean, Node, Object:options):void} - function for controlling the appearance when toggling enabled. + enabledAppearanceStrategy: SunConstants.componentEnabledListener, + /** * Converts a value to a string to be displayed in a Text node. NOTE: If this function can give different strings * to the same value depending on external state, it is recommended to rebuild the NumberPicker when that state @@ -376,7 +379,7 @@ class NumberPicker extends Node { this.mutate( options ); // No need to dispose because enabledProperty is disposed in Node - this.enabledProperty.link( SunConstants.getComponentEnabledListener( this, { disabledOpacity: options.disabledOpacity } ) ); + this.enabledProperty.link( enabled => options.enabledAppearanceStrategy( enabled, this, { disabledOpacity: options.disabledOpacity } ) ); // Dilate based on consistent technique which brings into account transform of this node. const focusBounds = this.localBounds.dilated( FocusHighlightPath.getDilationCoefficient( this ) );