src/aria/widgets/controllers/SelectController.js
function (charCode, keyCode) {
                var dataModel = this._dataModel;
                var report;
                if (domEvent.isNavigationKey(keyCode)) {
                    var newIdx;
                    var validationKey = false;
                    if (keyCode == domEvent.KC_LEFT || keyCode == domEvent.KC_UP) {
                        newIdx = dataModel.selectedIdx - 1;
                    } else if (keyCode == domEvent.KC_RIGHT || keyCode == domEvent.KC_DOWN) {
                        newIdx = dataModel.selectedIdx + 1;
                    } else if (keyCode == domEvent.KC_PAGE_UP) {
                        newIdx = dataModel.selectedIdx - (dataModel.pageSize - 1);
                    } else if (keyCode == domEvent.KC_PAGE_DOWN) {
                        newIdx = dataModel.selectedIdx + (dataModel.pageSize - 1);
                    } else if (keyCode == domEvent.KC_HOME) {
                        newIdx = 0;
                    } else if (keyCode == domEvent.KC_END) {
                        newIdx = dataModel.listContent.length - 1;
                    } else if (keyCode == domEvent.KC_ENTER) {
                        // when pressing enter, the currently highlighted item in the dropdown becomes the current
                        // value:
                        newIdx = dataModel.selectedIdx;
                        validationKey = true;
                    } else if (keyCode == domEvent.KC_ESCAPE) {
                        // pressing escape has no effect if the popup is not open
                        // it only closes the popup when it is open (does not update the data model)
                        if (this._listWidget) {
                            report = this._createReport(false);
                            report.displayDropDown = false;
                            report.cancelKeyStroke = true;
                            jsonUtils.setValue(dataModel, 'selectedIdx', dataModel.displayIdx);
                        }
                    } else if (keyCode == domEvent.KC_TAB) {
                        // when pressing tab, the currently selected item stays the current value:
                        newIdx = dataModel.displayIdx;
                        validationKey = true;
                    }
                    if (newIdx != null) {
                        this._setLastTypedKeys(null);
                        this._setDisplayIdx(newIdx);
                        report = this._createReport(validationKey);
                        // never cancel TAB keystroke, and ENTER should not be canceled when the list widget is no
                        // longer displayed
                        report.cancelKeyStroke = (keyCode != domEvent.KC_TAB && (keyCode != domEvent.KC_ENTER || this._listWidget != null));
                        if (this._listWidget && validationKey) {
                            report.displayDropDown = false;
                        }
                    }
                } else {
                    var lastTypedKeys = dataModel.lastTypedKeys;
                    var newMatch = (lastTypedKeys == null);
                    if (newMatch) {
                        lastTypedKeys = "";
                    }
                    var newLastTypedKeys;
                    if (keyCode == domEvent.KC_BACKSPACE) {
                        newLastTypedKeys = this._getTypedValueOnDelete(keyCode, lastTypedKeys, lastTypedKeys.length, lastTypedKeys.length).nextValue;
                        // we do not look for a new match when pressing backspace, only save the resulting lastTypedKeys
                    } else {
                        newLastTypedKeys = this._getTypedValue(charCode, lastTypedKeys, lastTypedKeys.length, lastTypedKeys.length).nextValue;
                        newLastTypedKeys = newLastTypedKeys.toLowerCase();
                        var matchingIndex = this._findMatch(newLastTypedKeys, newMatch);
                        if (matchingIndex == -1) {
                            matchingIndex = this._findLetterMatch(newLastTypedKeys);
                        }
                        if (matchingIndex > -1) {
                            this._setDisplayIdx(matchingIndex);
                        }
                    }
                    report = this._createReport(false);
                    report.cancelKeyStroke = true;
                    this._setLastTypedKeys(newLastTypedKeys);
                }
                return report;
            }
function (charCode, keyCode) {
                var dataModel = this._dataModel;
                var report;
                if (domEvent.isNavigationKey(keyCode)) {
                    var newIdx;
                    var validationKey = false;
                    if (keyCode == domEvent.KC_LEFT || keyCode == domEvent.KC_UP) {
                        newIdx = dataModel.selectedIdx - 1;
                    } else if (keyCode == domEvent.KC_RIGHT || keyCode == domEvent.KC_DOWN) {
                        newIdx = dataModel.selectedIdx + 1;
                    } else if (keyCode == domEvent.KC_PAGE_UP) {
                        newIdx = dataModel.selectedIdx - (dataModel.pageSize - 1);
                    } else if (keyCode == domEvent.KC_PAGE_DOWN) {
                        newIdx = dataModel.selectedIdx + (dataModel.pageSize - 1);
                    } else if (keyCode == domEvent.KC_HOME) {
                        newIdx = 0;
                    } else if (keyCode == domEvent.KC_END) {
                        newIdx = dataModel.listContent.length - 1;
                    } else if (keyCode == domEvent.KC_ENTER) {
                        // when pressing enter, the currently highlighted item in the dropdown becomes the current
                        // value:
                        newIdx = dataModel.selectedIdx;
                        validationKey = true;
                    } else if (keyCode == domEvent.KC_ESCAPE) {
                        // pressing escape has no effect if the popup is not open
                        // it only closes the popup when it is open (does not update the data model)
                        if (this._listWidget) {
                            report = this._createReport(false);
                            report.displayDropDown = false;
                            report.cancelKeyStroke = true;
                            jsonUtils.setValue(dataModel, 'selectedIdx', dataModel.displayIdx);
                        }
                    } else if (keyCode == domEvent.KC_TAB) {
                        // when pressing tab, the currently selected item stays the current value:
                        newIdx = dataModel.displayIdx;
                        validationKey = true;
                    }
                    if (newIdx != null) {
                        this._setLastTypedKeys(null);
                        this._setDisplayIdx(newIdx);
                        report = this._createReport(validationKey);
                        // never cancel TAB keystroke, and ENTER should not be canceled when the list widget is no
                        // longer displayed
                        report.cancelKeyStroke = (keyCode != domEvent.KC_TAB && (keyCode != domEvent.KC_ENTER || this._listWidget != null));
                        if (this._listWidget && validationKey) {
                            report.displayDropDown = false;
                        }
                    }
                } else {
                    var lastTypedKeys = dataModel.lastTypedKeys;
                    var newMatch = (lastTypedKeys == null);
                    if (newMatch) {
                        lastTypedKeys = "";
                    }
                    var newLastTypedKeys;
                    if (keyCode == domEvent.KC_BACKSPACE) {
                        newLastTypedKeys = this._getTypedValueOnDelete(keyCode, lastTypedKeys, lastTypedKeys.length, lastTypedKeys.length).nextValue;
                        // we do not look for a new match when pressing backspace, only save the resulting lastTypedKeys
                    } else {
                        newLastTypedKeys = this._getTypedValue(charCode, lastTypedKeys, lastTypedKeys.length, lastTypedKeys.length).nextValue;
                        newLastTypedKeys = newLastTypedKeys.toLowerCase();
                        var matchingIndex = this._findMatch(newLastTypedKeys, newMatch);
                        if (matchingIndex == -1) {
                            matchingIndex = this._findLetterMatch(newLastTypedKeys);
                        }
                        if (matchingIndex > -1) {
                            this._setDisplayIdx(matchingIndex);
                        }
                    }
                    report = this._createReport(false);
                    report.cancelKeyStroke = true;
                    this._setLastTypedKeys(newLastTypedKeys);
                }
                return report;
            }
function ( charCode , keyCode ) { var dataModel = this . _dataModel ; var report ; if ( domEvent . isNavigationKey ( keyCode ) ) { var newIdx ; var validationKey = false ; if ( keyCode == domEvent . KC_LEFT || keyCode == domEvent . KC_UP ) { newIdx = dataModel . selectedIdx - 1 ; } else if ( keyCode == domEvent . KC_RIGHT || keyCode == domEvent . KC_DOWN ) { newIdx = dataModel . selectedIdx + 1 ; } else if ( keyCode == domEvent . KC_PAGE_UP ) { newIdx = dataModel . selectedIdx - ( dataModel . pageSize - 1 ) ; } else if ( keyCode == domEvent . KC_PAGE_DOWN ) { newIdx = dataModel . selectedIdx + ( dataModel . pageSize - 1 ) ; } else if ( keyCode == domEvent . KC_HOME ) { newIdx = 0 ; } else if ( keyCode == domEvent . KC_END ) { newIdx = dataModel . listContent . length - 1 ; } else if ( keyCode == domEvent . KC_ENTER ) { // when pressing enter, the currently highlighted item in the dropdown becomes the current // value: newIdx = dataModel . selectedIdx ; validationKey = true ; } else if ( keyCode == domEvent . KC_ESCAPE ) { // pressing escape has no effect if the popup is not open // it only closes the popup when it is open (does not update the data model) if ( this . _listWidget ) { report = this . _createReport ( false ) ; report . displayDropDown = false ; report . cancelKeyStroke = true ; jsonUtils . setValue ( dataModel , 'selectedIdx' , dataModel . displayIdx ) ; } } else if ( keyCode == domEvent . KC_TAB ) { // when pressing tab, the currently selected item stays the current value: newIdx = dataModel . displayIdx ; validationKey = true ; } if ( newIdx != null ) { this . _setLastTypedKeys ( null ) ; this . _setDisplayIdx ( newIdx ) ; report = this . _createReport ( validationKey ) ; // never cancel TAB keystroke, and ENTER should not be canceled when the list widget is no // longer displayed report . cancelKeyStroke = ( keyCode != domEvent . KC_TAB && ( keyCode != domEvent . KC_ENTER || this . _listWidget != null ) ) ; if ( this . _listWidget && validationKey ) { report . displayDropDown = false ; } } } else { var lastTypedKeys = dataModel . lastTypedKeys ; var newMatch = ( lastTypedKeys == null ) ; if ( newMatch ) { lastTypedKeys = "" ; } var newLastTypedKeys ; if ( keyCode == domEvent . KC_BACKSPACE ) { newLastTypedKeys = this . _getTypedValueOnDelete ( keyCode , lastTypedKeys , lastTypedKeys . length , lastTypedKeys . length ) . nextValue ; // we do not look for a new match when pressing backspace, only save the resulting lastTypedKeys } else { newLastTypedKeys = this . _getTypedValue ( charCode , lastTypedKeys , lastTypedKeys . length , lastTypedKeys . length ) . nextValue ; newLastTypedKeys = newLastTypedKeys . toLowerCase ( ) ; var matchingIndex = this . _findMatch ( newLastTypedKeys , newMatch ) ; if ( matchingIndex == - 1 ) { matchingIndex = this . _findLetterMatch ( newLastTypedKeys ) ; } if ( matchingIndex > - 1 ) { this . _setDisplayIdx ( matchingIndex ) ; } } report = this . _createReport ( false ) ; report . cancelKeyStroke = true ; this . _setLastTypedKeys ( newLastTypedKeys ) ; } return report ; }
Verify a given keyStroke and return a report.
@param {Integer} charCode
@param {Integer} keyCode
@return {aria.widgets.controllers.reports.DropDownControllerReport}
Verify a given keyStroke and return a report .