1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-04 12:15:45 +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,
getGroup: function (value) this.activeGroup.commandline,
onChange: function (elem) {
onChange: function (elem, value) {
if (elem.inputField != dactyl.focusedElement)
try {
elem.selectionStart = elem.value.length;
@@ -113,7 +113,10 @@ var CommandWidgets = Class("CommandWidgets", {
if (!elem.collapsed)
dactyl.focus(elem);
},
onVisibility: function (elem, visible) { visible && dactyl.focus(elem); }
onVisibility: function (elem, visible) {
if (visible)
dactyl.focus(elem);
}
});
this.addElement({
@@ -191,7 +194,7 @@ var CommandWidgets = Class("CommandWidgets", {
.join(" "));
elem.value = val[1];
if (obj.onChange)
obj.onChange.call(this, elem);
obj.onChange.call(this, elem, val);
}
}, this);
@@ -799,10 +802,8 @@ var CommandLine = Module("commandline", {
]).toObject(),
{
blur: function onBlur(event) {
this.timeout(function () {
if (this.commandMode && event.originalTarget === this.widgets.active.command.inputField)
dactyl.focus(this.widgets.active.command.inputField);
});
if (this.commandMode && event.originalTarget === this.widgets.active.command.inputField)
dactyl.focus(this.widgets.active.command.inputField);
},
focus: function onFocus(event) {
if (!this.commandMode

View File

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

View File

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