From 684ac62d2bb1872e9808be7587fa1b22bab4b45b Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Fri, 26 Aug 2022 10:48:15 -0600 Subject: [PATCH] pass in Properties to (Rich)Text instead of their string values, https://github.com/phetsims/joist/issues/844 --- js/MeasuringTapeNode.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/js/MeasuringTapeNode.ts b/js/MeasuringTapeNode.ts index 85694be6..df8c7600 100644 --- a/js/MeasuringTapeNode.ts +++ b/js/MeasuringTapeNode.ts @@ -26,7 +26,7 @@ import optionize from '../../phet-core/js/optionize.js'; import StrictOmit from '../../phet-core/js/types/StrictOmit.js'; import StringUtils from '../../phetcommon/js/util/StringUtils.js'; import ModelViewTransform2 from '../../phetcommon/js/view/ModelViewTransform2.js'; -import { Circle, DragListener, Font, TColor, Image, Line, Node, NodeOptions, NodeTranslationOptions, Path, PressListenerEvent, Rectangle, Text } from '../../scenery/js/imports.js'; +import { Circle, DragListener, Font, Image, Line, Node, NodeOptions, NodeTranslationOptions, Path, PressListenerEvent, Rectangle, TColor, Text } from '../../scenery/js/imports.js'; import Tandem from '../../tandem/js/Tandem.js'; import NumberIO from '../../tandem/js/types/NumberIO.js'; import StringIO from '../../tandem/js/types/StringIO.js'; @@ -237,7 +237,7 @@ class MeasuringTapeNode extends Node { phetioDocumentation: 'The text content of the readout on the measuring tape' } ); - this.valueNode = new Text( readoutTextProperty.value, { + this.valueNode = new Text( readoutTextProperty, { font: options.textFont, fill: options.textColor, maxWidth: options.textMaxWidth @@ -355,8 +355,7 @@ class MeasuringTapeNode extends Node { tip.addInputListener( tipDragListener ); } - const updateTextReadout = ( text: string ) => { - this.valueNode.setText( text ); + const updateTextReadout = () => { this.valueNode.centerTop = this.baseImage.center.plus( options.textPosition.times( options.baseScale ) ); }; readoutTextProperty.link( updateTextReadout ); @@ -396,7 +395,7 @@ class MeasuringTapeNode extends Node { baseCrosshair.rotateAround( viewBasePosition, deltaAngle ); } - updateTextReadout( readoutTextProperty.value ); + updateTextReadout(); } ); this.disposeMeasuringTapeNode = () => {