Skip to content

Commit

Permalink
replace param button with focusButtonCallback #445
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jan 22, 2019
1 parent 1b498f2 commit 3c809e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions js/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ define( require => {
}

// @private the popup list box
this.listBox = new ComboBoxListBox( property, items, this.button,
this.hideListBox.bind( this ), options.tandem.createTandem( 'listBox' ), {
this.listBox = new ComboBoxListBox( property, items,
this.hideListBox.bind( this ), // callback to hide the list box
this.button.focus.bind( this.button ), // callback to transfer focus to button
options.tandem.createTandem( 'listBox' ), {
align: options.align,
highlightFill: options.highlightFill,
xMargin: options.xMargin,
Expand Down
16 changes: 8 additions & 8 deletions js/ComboBoxListBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ define( require => {
/**
* @param {Property} property
* @param {ComboBoxItem[]} items
* @param {ComboBoxButton} button TODO sun#445 would be nice if list box didn't need to know about button
* @param {function} hideCallback TODO sun#445 would be nice if list box didn't need hideCallback
* @param {function} hideListBoxCallback - called to hide the list box
* @param {function} focusButtonCallback - called to transfer focus to the combo box's button
* @param {Tandem} tandem
* @param {Object} [options]
*/
constructor( property, items, button, hideCallback, tandem, options ) {
constructor( property, items, hideListBoxCallback, focusButtonCallback, tandem, options ) {

options = _.extend( {

Expand Down Expand Up @@ -60,7 +60,7 @@ define( require => {
const listItemNode = event.currentTarget;
assert && assert( listItemNode instanceof ComboBoxListItemNode, 'expected a ComboBoxListItemNode' );

hideCallback();
hideListBoxCallback();
listItemNode.setHighlightVisible( false );
event.abort(); // prevent nodes (eg, controls) behind the list from receiving the event

Expand Down Expand Up @@ -101,8 +101,8 @@ define( require => {
const listItemNode = event.currentTarget;

property.value = listItemNode.item.value;
hideCallback();
button.focus();
hideListBoxCallback();
focusButtonCallback();
}
}
};
Expand Down Expand Up @@ -169,8 +169,8 @@ define( require => {
keydown: event => {
var keyCode = event.domEvent.keyCode;
if ( keyCode === KeyboardUtil.KEY_ESCAPE || keyCode === KeyboardUtil.KEY_TAB ) {
hideCallback();
button.focus();
hideListBoxCallback();
focusButtonCallback();
}
else if ( keyCode === KeyboardUtil.KEY_DOWN_ARROW || keyCode === KeyboardUtil.KEY_UP_ARROW ) {

Expand Down

0 comments on commit 3c809e8

Please sign in to comment.