Skip to content

Commit

Permalink
Some keyboard shortcuts doesn't work on macOS #663
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Dec 12, 2024
1 parent da19b8b commit 26d925b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
23 changes: 21 additions & 2 deletions packages/home/tabs-store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -647,13 +647,32 @@ export class ProjectEditorTab implements IHomeTab {
!(event.target instanceof HTMLInputElement) &&
!(event.target instanceof HTMLTextAreaElement)
) {
if (event.ctrlKey) {
if (event.key == "x") {
if (
(event.ctrlKey || event.metaKey) &&
!event.shiftKey &&
!event.altKey
) {
if (event.key == "z") {
undo();
} else if (event.key == "y") {
redo();
} else if (event.key == "x") {
cut();
} else if (event.key == "c") {
copy();
} else if (event.key == "v") {
paste();
} else if (event.key == "a") {
selectAll();
}
} else if (
!event.ctrlKey &&
!event.metaKey &&
!event.shiftKey &&
!event.altKey
) {
if (event.key == "Backspace" || event.key == "Delete") {
deleteSelection();
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions packages/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ function buildEditMenu(win: IWindow | undefined) {
id: "undo",
label: "Undo",
accelerator: "CmdOrCtrl+Z",
role: isMacOs() ? "undo" : undefined,
role: "undo",
click: function (item, focusedWindow) {
if (focusedWindow) {
const win = findWindowByBrowserWindow(focusedWindow);
Expand All @@ -488,7 +488,7 @@ function buildEditMenu(win: IWindow | undefined) {
id: "redo",
label: "Redo",
accelerator: "CmdOrCtrl+Y",
role: isMacOs() ? "redo" : undefined,
role: "redo",
click: function (item, focusedWindow) {
if (focusedWindow) {
const win = findWindowByBrowserWindow(focusedWindow);
Expand All @@ -507,7 +507,7 @@ function buildEditMenu(win: IWindow | undefined) {
{
label: "Cut",
accelerator: "CmdOrCtrl+X",
role: isMacOs() ? "cut" : undefined,
role: "cut",
click: function (item) {
if (win) {
win.browserWindow.webContents.send("cut");
Expand All @@ -517,7 +517,7 @@ function buildEditMenu(win: IWindow | undefined) {
{
label: "Copy",
accelerator: "CmdOrCtrl+C",
role: isMacOs() ? "copy" : undefined,
role: "copy",
click: function (item) {
if (win) {
win.browserWindow.webContents.send("copy");
Expand All @@ -527,7 +527,7 @@ function buildEditMenu(win: IWindow | undefined) {
{
label: "Paste",
accelerator: "CmdOrCtrl+V",
role: isMacOs() ? "paste" : undefined,
role: "paste",
click: function (item) {
if (win) {
win.browserWindow.webContents.send("paste");
Expand All @@ -537,7 +537,7 @@ function buildEditMenu(win: IWindow | undefined) {
{
label: "Delete",
accelerator: "Delete",
role: isMacOs() ? "delete" : undefined,
role: "delete",
click: function (item) {
if (win) {
win.browserWindow.webContents.send("delete");
Expand All @@ -549,8 +549,8 @@ function buildEditMenu(win: IWindow | undefined) {
},
{
label: "Select All",
accelerator: isMacOs() ? "CmdOrCtrl+A" : undefined,
role: isMacOs() ? "selectAll" : undefined,
accelerator: "CmdOrCtrl+A",
role: "selectAll",
click: function (item) {
if (win) {
win.browserWindow.webContents.send("select-all");
Expand Down
5 changes: 5 additions & 0 deletions packages/project-editor/features/page/PagesNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ export const PageStructure = observer(
deleteSelection() {
this.treeAdapter!.deleteSelection();
}
selectAll() {
this.treeAdapter!.selectItems(
this.treeAdapter!.allRows.map(row => row.item)
);
}
onFocus = () => {
this.context.navigationStore.setSelectedPanel(this);
};
Expand Down

0 comments on commit 26d925b

Please sign in to comment.