Commit 9caa8ef4 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

fix #84 again: Undo problem. use same shortcut for all platforms (needs some testing on Windows)

parent ebbd6ad1
......@@ -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");
......
......@@ -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({
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment