From 1c783838d4820c1f588c54ed2a6ef8ba02205e71 Mon Sep 17 00:00:00 2001 From: Chris Malley Date: Thu, 16 Dec 2021 15:15:52 -0700 Subject: [PATCH] add hotkey for hiding ruler, https://github.com/phetsims/geometric-optics/issues/258 --- js/common/view/GORulerNode.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/common/view/GORulerNode.ts b/js/common/view/GORulerNode.ts index bd53066c..c0305a70 100644 --- a/js/common/view/GORulerNode.ts +++ b/js/common/view/GORulerNode.ts @@ -19,7 +19,7 @@ import merge from '../../../../phet-core/js/merge.js'; import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js'; import PhetFont from '../../../../scenery-phet/js/PhetFont.js'; import RulerNode from '../../../../scenery-phet/js/RulerNode.js'; -import { DragListener, Font, KeyboardDragListener, Node, SceneryEvent } from '../../../../scenery/js/imports.js'; +import { DragListener, Font, KeyboardDragListener, KeyboardUtils, Node, SceneryEvent } from '../../../../scenery/js/imports.js'; import geometricOptics from '../../geometricOptics.js'; import geometricOpticsStrings from '../../geometricOpticsStrings.js'; import GOConstants from '../GOConstants.js'; @@ -183,6 +183,14 @@ class GORulerNode extends Node { } ) ); this.addInputListener( keyboardDragListener ); + keyboardDragListener.addHotkeys( [ { + keys: [ KeyboardUtils.KEY_H, KeyboardUtils.KEY_R ], //TODO https://github.com/phetsims/scenery/issues/1331 replace with KEY_ESCAPE + callback: () => { + ruler.visibleProperty.value = false; + this.iconNode.focus(); + } + } ] ); + // When the transform changes, up the input listeners zoomTransformProperty.link( zoomTransform => { this.dragListener.transform = zoomTransform;