From a5f65213702c98c39ea968a4dd97b15f992f8951 Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Wed, 22 May 2024 16:16:06 -0600 Subject: [PATCH] fix dragBoundsProperty and cursor for electromagnet.coil.backgroundNode, https://github.com/phetsims/faradays-electromagnetic-lab/issues/169 --- js/common/view/ElectromagnetNode.ts | 1 + js/common/view/FELScreenView.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/js/common/view/ElectromagnetNode.ts b/js/common/view/ElectromagnetNode.ts index 3a6035a0..709c9bdf 100644 --- a/js/common/view/ElectromagnetNode.ts +++ b/js/common/view/ElectromagnetNode.ts @@ -34,6 +34,7 @@ export default class ElectromagnetNode extends FELMovableNode { const options = optionize()( {}, providedOptions ); const coilNode = new CoilNode( electromagnet.coil, electromagnet, { + dragBoundsProperty: options.dragBoundsProperty, tandem: options.tandem.createTandem( 'coilNode' ) } ); diff --git a/js/common/view/FELScreenView.ts b/js/common/view/FELScreenView.ts index f143de3c..6bdf1151 100644 --- a/js/common/view/FELScreenView.ts +++ b/js/common/view/FELScreenView.ts @@ -30,6 +30,8 @@ import DerivedProperty from '../../../../axon/js/DerivedProperty.js'; import isSettingPhetioStateProperty from '../../../../tandem/js/isSettingPhetioStateProperty.js'; import FELQueryParameters from '../FELQueryParameters.js'; import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js'; +import BarMagnetNode from './BarMagnetNode.js'; +import ElectromagnetNode from './ElectromagnetNode.js'; type SelfOptions = { @@ -185,7 +187,7 @@ export default class FELScreenView extends ScreenView { panelsBoundsProperty: TReadOnlyProperty, magnetPositionProperty: Property, pickupCoilPositionProperty: Property, - magnetNode: Node, + magnetNode: BarMagnetNode | ElectromagnetNode, pickupCoilNode: PickupCoilNode ): void { Multilink.multilink( [ lockedToAxisProperty, panelsBoundsProperty ], ( lockToAxis, panelsBounds ) => { @@ -209,6 +211,9 @@ export default class FELScreenView extends ScreenView { // Change the cursors to indicate that drag direction is constrained to horizontal. magnetNode.cursor = 'ew-resize'; + if ( magnetNode instanceof ElectromagnetNode ) { + magnetNode.backgroundNode.cursor = 'ew-resize'; + } pickupCoilNode.cursor = 'ew-resize'; pickupCoilNode.backgroundNode.cursor = 'ew-resize'; } @@ -220,6 +225,9 @@ export default class FELScreenView extends ScreenView { // Restore cursors. magnetNode.cursor = 'pointer'; + if ( magnetNode instanceof ElectromagnetNode ) { + magnetNode.backgroundNode.cursor = 'pointer'; + } pickupCoilNode.cursor = 'pointer'; pickupCoilNode.backgroundNode.cursor = 'pointer'; }