1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-07 00:54:13 +01:00

Fix lost key presses when starting find mode during page load.

This commit is contained in:
Kris Maglione
2011-02-03 12:35:37 -05:00
parent d9ad94fb1e
commit e769c21566
3 changed files with 14 additions and 11 deletions

View File

@@ -102,7 +102,7 @@ var CommandWidgets = Class("CommandWidgets", {
}, },
getElement: CommandWidgets.getEditor, getElement: CommandWidgets.getEditor,
getGroup: function (value) this.activeGroup.commandline, getGroup: function (value) this.activeGroup.commandline,
onChange: function (elem) { onChange: function (elem, value) {
if (elem.inputField != dactyl.focusedElement) if (elem.inputField != dactyl.focusedElement)
try { try {
elem.selectionStart = elem.value.length; elem.selectionStart = elem.value.length;
@@ -113,7 +113,10 @@ var CommandWidgets = Class("CommandWidgets", {
if (!elem.collapsed) if (!elem.collapsed)
dactyl.focus(elem); dactyl.focus(elem);
}, },
onVisibility: function (elem, visible) { visible && dactyl.focus(elem); } onVisibility: function (elem, visible) {
if (visible)
dactyl.focus(elem);
}
}); });
this.addElement({ this.addElement({
@@ -191,7 +194,7 @@ var CommandWidgets = Class("CommandWidgets", {
.join(" ")); .join(" "));
elem.value = val[1]; elem.value = val[1];
if (obj.onChange) if (obj.onChange)
obj.onChange.call(this, elem); obj.onChange.call(this, elem, val);
} }
}, this); }, this);
@@ -799,10 +802,8 @@ var CommandLine = Module("commandline", {
]).toObject(), ]).toObject(),
{ {
blur: function onBlur(event) { blur: function onBlur(event) {
this.timeout(function () { if (this.commandMode && event.originalTarget === this.widgets.active.command.inputField)
if (this.commandMode && event.originalTarget === this.widgets.active.command.inputField) dactyl.focus(this.widgets.active.command.inputField);
dactyl.focus(this.widgets.active.command.inputField);
});
}, },
focus: function onFocus(event) { focus: function onFocus(event) {
if (!this.commandMode if (!this.commandMode

View File

@@ -510,6 +510,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
} }
catch (e) {} catch (e) {}
util.dumpStack(" ================ FOCUS CONTENT ================ ");
if (clearFocusedElement) { if (clearFocusedElement) {
if (dactyl.focusedElement) if (dactyl.focusedElement)
dactyl.focusedElement.blur(); dactyl.focusedElement.blur();

View File

@@ -29,6 +29,7 @@ var RangeFinder = Module("rangefinder", {
get options() this.modules.options, get options() this.modules.options,
openPrompt: function (mode) { openPrompt: function (mode) {
this.commandline;
this.CommandMode(mode).open(); this.CommandMode(mode).open();
if (this.rangeFind && this.rangeFind.window.get() === this.window) if (this.rangeFind && this.rangeFind.window.get() === this.window)
@@ -318,6 +319,8 @@ var RangeFind = Class("RangeFind", {
this.lastString = ""; this.lastString = "";
}, },
get store() this.content.document.dactylStore = this.content.document.dactylStore || {},
get backward() this.finder.findBackwards, get backward() this.finder.findBackwards,
get matchCase() this.finder.caseSensitive, get matchCase() this.finder.caseSensitive,
@@ -336,9 +339,7 @@ var RangeFind = Class("RangeFind", {
get findString() this.lastString, get findString() this.lastString,
get selectedRange() { get selectedRange() {
let win = this.content, store = this.content.document.dactylStore;; let win = this.store.focusedFrame && this.store.focusedFrame.get() || this.content;
if (store)
win = store.focusedFrame && store.focusedFrame.get() || win;
let selection = win.getSelection(); let selection = win.getSelection();
return (selection.rangeCount ? selection.getRangeAt(0) : this.ranges[0].range).cloneRange(); return (selection.rangeCount ? selection.getRangeAt(0) : this.ranges[0].range).cloneRange();
@@ -349,7 +350,7 @@ var RangeFind = Class("RangeFind", {
this.range.selectionController.scrollSelectionIntoView( this.range.selectionController.scrollSelectionIntoView(
this.range.selectionController.SELECTION_NORMAL, 0, false); this.range.selectionController.SELECTION_NORMAL, 0, false);
services.focus.focusedWindow = range.startContainer.ownerDocument.defaultView; this.store.focusedFrame = Cu.getWeakReference(range.startContainer.ownerDocument.defaultView);
}, },
cancel: function () { cancel: function () {