mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-29 11:04:12 -05:00
:electron: Adding hotkeys for mac (#6067)
* adding hotkeys for mac * release notes * window mac menu * fix window
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { MenuItemConstructorOptions, Menu, BrowserWindow } from 'electron';
|
import { MenuItemConstructorOptions, Menu, BrowserWindow, app } from 'electron';
|
||||||
|
|
||||||
export function getMenu() {
|
export function getMenu() {
|
||||||
const template: MenuItemConstructorOptions[] = [
|
const template: MenuItemConstructorOptions[] = [
|
||||||
@@ -60,7 +60,118 @@ export function getMenu() {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Edit',
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
label: 'Undo',
|
||||||
|
enabled: false,
|
||||||
|
accelerator: 'CmdOrCtrl+Z',
|
||||||
|
click: function (_menuItem, focusedWin) {
|
||||||
|
// Undo
|
||||||
|
if (focusedWin) {
|
||||||
|
(focusedWin as BrowserWindow).webContents.executeJavaScript(
|
||||||
|
'__actionsForMenu.undo()',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Redo',
|
||||||
|
enabled: false,
|
||||||
|
accelerator: 'Shift+CmdOrCtrl+Z',
|
||||||
|
click: function (_menuItem, focusedWin) {
|
||||||
|
// Redo
|
||||||
|
if (focusedWin) {
|
||||||
|
(focusedWin as BrowserWindow).webContents.executeJavaScript(
|
||||||
|
'__actionsForMenu.redo()',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'separator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: 'cut',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: 'copy',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: 'paste',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: 'pasteAndMatchStyle',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: 'delete',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: 'selectAll',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: 'window',
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
role: 'minimize',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
// Mac specific menu
|
||||||
|
const name = app.getName();
|
||||||
|
template.unshift({
|
||||||
|
label: name,
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
role: 'hide',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: 'hideOthers',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: 'unhide',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'separator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
role: 'quit',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Window menu
|
||||||
|
const windowIdx = template.findIndex(t => t.role === 'window');
|
||||||
|
template[windowIdx].submenu = [
|
||||||
|
{
|
||||||
|
label: 'Close',
|
||||||
|
accelerator: 'CmdOrCtrl+W',
|
||||||
|
role: 'close',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Minimize',
|
||||||
|
accelerator: 'CmdOrCtrl+M',
|
||||||
|
role: 'minimize',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Zoom',
|
||||||
|
role: 'zoom',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'separator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Bring All to Front',
|
||||||
|
role: 'front',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return Menu.buildFromTemplate(template);
|
return Menu.buildFromTemplate(template);
|
||||||
}
|
}
|
||||||
|
|||||||
6
upcoming-release-notes/6067.md
Normal file
6
upcoming-release-notes/6067.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
category: Bugfix
|
||||||
|
authors: [MikesGlitch]
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix mac desktop app hotkeys
|
||||||
Reference in New Issue
Block a user