mirror of
https://github.com/aljazceru/goose.git
synced 2026-01-02 22:14:26 +01:00
Fix global shortcuts (#1904)
This commit is contained in:
@@ -162,12 +162,6 @@ export default function MoreMenu({
|
||||
}
|
||||
};
|
||||
|
||||
const handleVersionSelect = (version: string) => {
|
||||
setOpen(false);
|
||||
setShowVersions(false);
|
||||
window.electron.createChatWindow(undefined, undefined, version);
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
|
||||
@@ -224,36 +224,22 @@ const createChat = async (
|
||||
});
|
||||
}
|
||||
|
||||
// DevTools shortcut management
|
||||
const registerDevToolsShortcut = (window: BrowserWindow) => {
|
||||
globalShortcut.register('Alt+Command+I', () => {
|
||||
window.webContents.openDevTools();
|
||||
});
|
||||
};
|
||||
|
||||
const unregisterDevToolsShortcut = () => {
|
||||
globalShortcut.unregister('Alt+Command+I');
|
||||
};
|
||||
|
||||
// Register shortcuts when window is focused
|
||||
mainWindow.on('focus', () => {
|
||||
registerDevToolsShortcut(mainWindow);
|
||||
// Register reload shortcut
|
||||
globalShortcut.register('CommandOrControl+R', () => {
|
||||
// Set up local keyboard shortcuts that only work when the window is focused
|
||||
mainWindow.webContents.on('before-input-event', (event, input) => {
|
||||
if (input.key === 'r' && input.meta) {
|
||||
mainWindow.reload();
|
||||
});
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// Unregister shortcuts when window loses focus
|
||||
mainWindow.on('blur', () => {
|
||||
unregisterDevToolsShortcut();
|
||||
globalShortcut.unregister('CommandOrControl+R');
|
||||
if (input.key === 'i' && input.alt && input.meta) {
|
||||
mainWindow.webContents.openDevTools();
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
windowMap.set(windowId, mainWindow);
|
||||
mainWindow.on('closed', () => {
|
||||
windowMap.delete(windowId);
|
||||
unregisterDevToolsShortcut();
|
||||
goosedProcess.kill();
|
||||
});
|
||||
return mainWindow;
|
||||
|
||||
Reference in New Issue
Block a user