2017-12-19 05:12:32 -05:00
|
|
|
import Mousetrap from 'mousetrap';
|
2017-10-10 05:10:11 -04:00
|
|
|
import ShortcutsNavigation from './shortcuts_navigation';
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-10-10 05:10:11 -04:00
|
|
|
export default class ShortcutsFindFile extends ShortcutsNavigation {
|
|
|
|
constructor(projectFindFile) {
|
|
|
|
super();
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-10-10 05:10:11 -04:00
|
|
|
const oldStopCallback = Mousetrap.stopCallback;
|
|
|
|
this.projectFindFile = projectFindFile;
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-10-10 05:10:11 -04:00
|
|
|
Mousetrap.stopCallback = (e, element, combo) => {
|
|
|
|
if (
|
|
|
|
element === this.projectFindFile.inputElement[0] &&
|
|
|
|
(combo === 'up' || combo === 'down' || combo === 'esc' || combo === 'enter')
|
|
|
|
) {
|
2018-06-15 11:58:27 -04:00
|
|
|
// when press up/down key in textbox, cursor prevent to move to home/end
|
|
|
|
e.preventDefault();
|
2017-10-10 05:10:11 -04:00
|
|
|
return false;
|
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-10-10 05:10:11 -04:00
|
|
|
return oldStopCallback(e, element, combo);
|
|
|
|
};
|
|
|
|
|
|
|
|
Mousetrap.bind('up', this.projectFindFile.selectRowUp);
|
|
|
|
Mousetrap.bind('down', this.projectFindFile.selectRowDown);
|
|
|
|
Mousetrap.bind('esc', this.projectFindFile.goToTree);
|
|
|
|
Mousetrap.bind('enter', this.projectFindFile.goToBlob);
|
|
|
|
}
|
|
|
|
}
|