diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js index 4b2a9e2a41e4cd5c7bd891e08f665497702067fe..6dada642e107aa0e4111398f2a15e3f84f87de7b 100644 --- a/pd/nw/pd_canvas.js +++ b/pd/nw/pd_canvas.js @@ -350,20 +350,23 @@ var canvas_events = (function() { break; case 90: if (cmd_or_ctrl_key(evt)) { // ctrl-z undo/redo - // We have to catch undo and redo shortcuts here - // instead of using menu shortcuts. There is a - // separate undo/redo buffer when we're editing - // inside an object box we need to use, and a - // menu item shortcut would not propogate down - // to the DOM in that case. - - // Not sure if DOM has listeners for undo/redo, - // so for now (May 7, 2016) we catch them here... - if (evt.shiftKey) { - pdgui.pdsend(name, "redo"); - } else { - pdgui.pdsend(name, "undo"); - } + // We have to catch undo and redo here. + // undo and redo have nw.js menu item shortcuts, + // and those shortcuts don't behave consistently + // across platforms: + // Gnu/Linux: key events for the shortcut do not + // propogate down to the DOM + // OSX: key events for the shortcut _do_ propogate + // down to the DOM + // Windows: not sure... + + // Solution-- let the menu item shortcuts handle + // undo/redo functionality, and do nothing here... + //if (evt.shiftKey) { + // pdgui.pdsend(name, "redo"); + //} else { + // pdgui.pdsend(name, "undo"); + //} } break; @@ -1153,8 +1156,7 @@ function nw_create_patch_window_menus(gui, w, name) { minit(m.edit.undo, { enabled: true, click: function () { - if (process.platform === "darwin" && - canvas_events.get_state() === "text") { + if (canvas_events.get_state() === "text") { document.execCommand("undo", false, null); } else { pdgui.pdsend(name, "undo"); @@ -1164,8 +1166,7 @@ function nw_create_patch_window_menus(gui, w, name) { minit(m.edit.redo, { enabled: true, click: function () { - if (process.platform === "darwin" && - canvas_events.get_state() === "text") { + if (canvas_events.get_state() === "text") { document.execCommand("redo", false, null); } else { pdgui.pdsend(name, "redo"); diff --git a/pd/nw/pd_menus.js b/pd/nw/pd_menus.js index c1dfaccc9efc1dda1816cb61dbae003c1ff6ed8e..4f9dc8b4864e25859ae5d1cce5e9501ce15ff0b5 100644 --- a/pd/nw/pd_menus.js +++ b/pd/nw/pd_menus.js @@ -159,11 +159,15 @@ function create_menu(gui, type) { if (canvas_menu) { edit_menu.append(m.edit.undo = new gui.MenuItem({ label: l("menu.undo"), - tooltip: l("menu.undo_tt") + tooltip: l("menu.undo_tt"), + key: "z", + modifiers: cmd_or_ctrl })); edit_menu.append(m.edit.redo = new gui.MenuItem({ label: l("menu.redo"), - tooltip: l("menu.redo_tt") + tooltip: l("menu.redo_tt"), + key: "z", + modifiers: "shift+" + cmd_or_ctrl })); edit_menu.append(new gui.MenuItem({ type: "separator" })); edit_menu.append(m.edit.cut = new gui.MenuItem({