Skip to content

Commit

Permalink
split up item listener, #462
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jan 22, 2019
1 parent 4eacb80 commit bd98721
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions js/ComboBoxListBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ define( require => {

}, options );

//TODO sun#462 replace fireEmitter and selectionListener with a standard scenery listener in the future
const firedEmitter = new Emitter( {
argumentTypes: [ { validValue: Event } ],

Expand All @@ -77,16 +78,21 @@ define( require => {
phetioType: EmitterIO( [ { name: 'event', type: VoidIO } ] ) // TODO sun#405 Should type be EventIO or DOMEventIO?
} );

// listener that we'll attach to each ComboBoxListItemNode (each item in the list)
const listItemNodeListener = {
// Highlights the item that the pointer is over.
const highlightListener = {

enter( event ) {
event.currentTarget.setHighlightVisible( true );
},

exit( event ) {
event.currentTarget.setHighlightVisible( false );
},
}
};

//TODO sun#462 replace fireEmitter and selectionListener with a standard scenery listener in the future
// Handles selection from the list box.
const selectionListener = {

down( event ) {
event.abort(); // prevent click-to-dismiss on the list
Expand Down Expand Up @@ -131,7 +137,8 @@ define( require => {
} );
listItemNodes.push( listItemNode );

listItemNode.addInputListener( listItemNodeListener );
listItemNode.addInputListener( highlightListener );
listItemNode.addInputListener( selectionListener );
} );

const content = new VBox( {
Expand Down

0 comments on commit bd98721

Please sign in to comment.