Skip to content

Commit

Permalink
add hotkey for hiding ruler, #258
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Dec 16, 2021
1 parent 64ff02a commit 1c78383
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion js/common/view/GORulerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1c78383

Please sign in to comment.