Skip to content

Commit

Permalink
pass in Properties to (Rich)Text instead of their string values, phet…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Aug 26, 2022
1 parent 22a1097 commit 684ac62
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions js/MeasuringTapeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -396,7 +395,7 @@ class MeasuringTapeNode extends Node {
baseCrosshair.rotateAround( viewBasePosition, deltaAngle );
}

updateTextReadout( readoutTextProperty.value );
updateTextReadout();
} );

this.disposeMeasuringTapeNode = () => {
Expand Down

0 comments on commit 684ac62

Please sign in to comment.