Skip to content

Commit

Permalink
simplify focus listeners, #683
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jan 23, 2021
1 parent a138da1 commit 6270e6d
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions js/HomeScreenButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ class HomeScreenButton extends VBox {
} );
this.addInputListener( fireListener );
this.addInputListener( { focus: event => { !isSelectedProperty.value && fireListener.fire( event ); } } );

// when a screen reader is in use, the button may be selected with the virtual cursor
// without focus landing on the button - toggle focus (and therefore size) in this case
this.addInputListener( { click: () => this.focus() } );

this.addInputListener( {
focus: () => isHighlightedProperty.set( true ),
blur: () => isHighlightedProperty.set( false ),
Expand All @@ -202,16 +207,6 @@ class HomeScreenButton extends VBox {
}
} );

// pdom support for click listeners on the screen buttons
const toggleListener = () => {
this.focus();
};
this.addInputListener( { focus: toggleListener } );

// when a screen reader is in use, the button may be selected with the virtual cursor
// without focus landing on the button - toggle focus (and therefore size) in this case
this.addInputListener( { click: toggleListener } );

// set the mouseArea and touchArea to be the whole local bounds of this node, because if it just relies on the
// bounds of the icon and text, then there is a gap in between them. Since the button can change size, this
// assignment needs to happen anytime the bounds change.
Expand Down

0 comments on commit 6270e6d

Please sign in to comment.