Add shortcuts to select next/previous tab
This commit is contained in:
@@ -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
|
||||
});
|
||||
|
@@ -136,7 +136,8 @@ var createTemplate = function(mainWindow, config) {
|
||||
}
|
||||
}, ]
|
||||
});
|
||||
template.push({
|
||||
|
||||
const window_menu = {
|
||||
label: '&Window',
|
||||
submenu: [{
|
||||
label: 'Minimize',
|
||||
@@ -166,7 +167,27 @@ var createTemplate = function(mainWindow, config) {
|
||||
}
|
||||
};
|
||||
})]
|
||||
});
|
||||
}
|
||||
|
||||
if (config.teams.length > 1) {
|
||||
window_menu.submenu = window_menu.submenu.concat([{
|
||||
type: 'separator'
|
||||
}, {
|
||||
label: 'Select Next Team',
|
||||
accelerator: (process.platform === 'darwin') ? 'Alt+Cmd+Right' : 'CmdOrCtrl+Tab',
|
||||
click: () => {
|
||||
mainWindow.webContents.send('select-next-tab');
|
||||
}
|
||||
}, {
|
||||
label: 'Select Previous Team',
|
||||
accelerator: (process.platform === 'darwin') ? 'Alt+Cmd+Left' : 'CmdOrCtrl+Shift+Tab',
|
||||
click: () => {
|
||||
mainWindow.webContents.send('select-previous-tab');
|
||||
}
|
||||
}]);
|
||||
}
|
||||
template.push(window_menu);
|
||||
|
||||
return template;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user