Skip to content

Commit

Permalink
Add isInteractiveHighlighting, see phetsims/scenery#1653
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Sep 3, 2024
1 parent 50e8db7 commit 67aa281
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions js/accessibility/grab-drag/GrabDragInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import EnabledComponent, { EnabledComponentOptions } from '../../../../axon/js/E
import assertHasProperties from '../../../../phet-core/js/assertHasProperties.js';
import getGlobal from '../../../../phet-core/js/getGlobal.js';
import StringUtils from '../../../../phetcommon/js/util/StringUtils.js';
import { Association, DragListener, HighlightFromNode, HighlightPath, InteractiveHighlightingNode, keyboardDraggingKeys, KeyboardDragListener, KeyboardListener, Node, NodeOptions, ParallelDOMOptions, PDOMPeer, PDOMValueType, SceneryEvent, SceneryListenerFunction, SceneryNullableListenerFunction, TInputListener, Voicing, VoicingNode } from '../../../../scenery/js/imports.js';
import { Association, DragListener, HighlightFromNode, HighlightPath, InteractiveHighlightingNode, isInteractiveHighlighting, keyboardDraggingKeys, KeyboardDragListener, KeyboardListener, Node, NodeOptions, ParallelDOMOptions, PDOMPeer, PDOMValueType, SceneryEvent, SceneryListenerFunction, SceneryNullableListenerFunction, TInputListener, Voicing, VoicingNode } from '../../../../scenery/js/imports.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import AriaLiveAnnouncer from '../../../../utterance-queue/js/AriaLiveAnnouncer.js';
import ResponsePacket from '../../../../utterance-queue/js/ResponsePacket.js';
Expand Down Expand Up @@ -745,16 +745,13 @@ export default class GrabDragInteraction extends EnabledComponent {
*/
private updateFocusHighlights(): void {

// TODO: If we always cast to InteractiveHighlightingNode, how about a new type like MaybeInteractiveHighlightingNode and pass that in to the constructor, see https://github.com/phetsims/scenery-phet/issues/869
const interactiveHighlightingNode = this.node as InteractiveHighlightingNode;

if ( this.grabDragModel.interactionState === 'grabbable' ) {
this.node.focusHighlight = this.grabFocusHighlight;
interactiveHighlightingNode.isInteractiveHighlighting && interactiveHighlightingNode.setInteractiveHighlight( this.grabInteractiveHighlight );
isInteractiveHighlighting( this.node ) && this.node.setInteractiveHighlight( this.grabInteractiveHighlight );
}
else {
this.node.focusHighlight = this.dragFocusHighlight;
interactiveHighlightingNode.isInteractiveHighlighting && interactiveHighlightingNode.setInteractiveHighlight( this.dragInteractiveHighlight );
isInteractiveHighlighting( this.node ) && this.node.setInteractiveHighlight( this.dragInteractiveHighlight );
}
}

Expand Down

0 comments on commit 67aa281

Please sign in to comment.