Add shortcuts to select next/previous tab

This commit is contained in:
Yuya Ochiai
2016-05-19 00:25:21 +09:00
parent 8f936c1725
commit 0bb56291ed
2 changed files with 31 additions and 3 deletions

View File

@@ -54,9 +54,16 @@ var MainPage = React.createClass({
loginQueue: loginQueue
});
});
// can't switch tabs sequencially for some reason...
ipcRenderer.on('switch-tab', (event, key) => {
this.handleSelect(key);
});
ipcRenderer.on('select-next-tab', (event) => {
this.handleSelect(this.state.key + 1);
});
ipcRenderer.on('select-previous-tab', (event) => {
this.handleSelect(this.state.key - 1);
});
var focusListener = function() {
var webview = document.getElementById('mattermostView' + thisObj.state.key);
@@ -72,7 +79,7 @@ var MainPage = React.createClass({
});
},
handleSelect: function(key) {
const newKey = key % this.props.teams.length;
const newKey = (this.props.teams.length + key) % this.props.teams.length;
this.setState({
key: newKey
});