From caf1274df9e5d62624175b84bb31241808829740 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sun, 14 Sep 2008 21:20:56 +0000 Subject: [PATCH] Cancel macro playback on . --- content/events.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/content/events.js b/content/events.js index a16af89f..50f5bde0 100644 --- a/content/events.js +++ b/content/events.js @@ -510,6 +510,9 @@ liberator.Events = function () //{{{ if ((now - then) % 1000 < 10) liberator.dump("waited: " + (now - then) + " ms\n"); + if (!liberator.modes.isReplaying) + return false; + if (liberator.buffer.loaded > 0) { liberator.sleep(250); @@ -842,13 +845,12 @@ liberator.Events = function () //{{{ evt.noremap = noremap; elem.dispatchEvent(evt); // stop feeding keys if page loading failed - if (liberator.modes.isReplaying) - { - if (!waitForPageLoaded()) - return; - // else // a short break between keys often helps - // liberator.sleep(50); - } + if (!liberator.modes.isReplaying) + return false; + if (!waitForPageLoaded()) + return; + // else // a short break between keys often helps + // liberator.sleep(50); } return true; }, @@ -1125,6 +1127,7 @@ liberator.Events = function () //{{{ { liberator.modes.isRecording = false; liberator.log("Recorded " + currentMacro + ": " + macros.get(currentMacro), 9); + liberator.echo("Recorded macro '" + currentMacro + "'"); event.preventDefault(); event.stopPropagation(); return true; @@ -1136,6 +1139,19 @@ liberator.Events = function () //{{{ } } + if (liberator.modes.isReplaying) + { + // XXX: Prevents using in a macro. + if (key == "") + { + liberator.modes.isReplaying = false; + liberator.echo("Canceled playback of macro '" + lastMacro + "'"); + event.preventDefault(); + event.stopPropagation(); + return true; + } + } + var stop = true; // set to false if we should NOT consume this event but let Firefox handle it var win = document.commandDispatcher.focusedWindow;