1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 06:08:02 +01:00

Kludge the stupid urlbar focus bug better

This commit is contained in:
Kris Maglione
2008-12-18 21:37:44 -05:00
parent c094a2dd2b
commit 947311dfdf
2 changed files with 68 additions and 65 deletions

View File

@@ -33,6 +33,7 @@ function AutoCommands() //{{{
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
var store = []; var store = [];
var lastFocus = null;
function matchAutoCmd(autoCmd, event, regex) function matchAutoCmd(autoCmd, event, regex)
{ {
@@ -1086,13 +1087,13 @@ function Events() //{{{
if (win && win.top == content && liberator.has("tabs")) if (win && win.top == content && liberator.has("tabs"))
tabs.localStore.focusedFrame = win; tabs.localStore.focusedFrame = win;
try
{
if (elem && elem.readOnly) if (elem && elem.readOnly)
return; return;
if (elem && ( if ((elem instanceof HTMLInputElement && /^(text|password)$/.test(elem.type)) ||
(elem instanceof HTMLInputElement && (elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password")) || (elem instanceof HTMLSelectElement))
(elem instanceof HTMLSelectElement)
))
{ {
this.wantsModeReset = false; this.wantsModeReset = false;
liberator.mode = modes.INSERT; liberator.mode = modes.INSERT;
@@ -1101,7 +1102,7 @@ function Events() //{{{
return; return;
} }
if (elem && elem instanceof HTMLTextAreaElement) if (elem instanceof HTMLTextAreaElement)
{ {
this.wantsModeReset = false; this.wantsModeReset = false;
if (options["insertmode"]) if (options["insertmode"])
@@ -1131,20 +1132,32 @@ function Events() //{{{
} }
} }
if (liberator.mode == modes.INSERT || urlbar = document.getElementById("urlbar");
liberator.mode == modes.TEXTAREA || if (focus == null && urlbar && urlbar.inputField == lastFocus)
liberator.mode == modes.MESSAGE || liberator.threadYield(true);
liberator.mode == modes.VISUAL)
if (liberator.mode & (modes.INSERT | modes.TEXTAREA | modes.MESSAGE | modes.VISUAL))
{ {
// FIXME: currently this hack is disabled to make macros work if (0) // FIXME: currently this hack is disabled to make macros work
// this.wantsModeReset = true; {
// setTimeout(function () { this.wantsModeReset = true;
// if (events.wantsModeReset) setTimeout(function () {
// { if (events.wantsModeReset)
// events.wantsModeReset = false; {
events.wantsModeReset = false;
modes.reset(); modes.reset();
// } }
// }, 0); }, 0);
}
else
{
modes.reset();
}
}
}
finally
{
lastFocus = elem;
} }
}, },
@@ -1198,7 +1211,6 @@ function Events() //{{{
catch (e) {} catch (e) {}
modes.reset(); modes.reset();
liberator.focusContent(true);
break; break;
case modes.VISUAL: case modes.VISUAL:
@@ -1216,14 +1228,9 @@ function Events() //{{{
case modes.INSERT: case modes.INSERT:
if ((modes.extended & modes.TEXTAREA) && !options["insertmode"]) if ((modes.extended & modes.TEXTAREA) && !options["insertmode"])
{
liberator.mode = modes.TEXTAREA; liberator.mode = modes.TEXTAREA;
}
else else
{
modes.reset(); modes.reset();
liberator.focusContent(true);
}
break; break;
default: // HINTS, CUSTOM or COMMAND_LINE default: // HINTS, CUSTOM or COMMAND_LINE

View File

@@ -116,13 +116,7 @@ const modes = (function () //{{{
options.setPref("accessibility.browsewithcaret", false); options.setPref("accessibility.browsewithcaret", false);
statusline.updateUrl(); statusline.updateUrl();
// Kludge to prevent the input field losing focus on MS/Mac
setTimeout(function () {
let focus = document.commandDispatcher.focusedElement;
let urlbar = document.getElementById("urlbar");
if (!urlbar || focus != urlbar.inputField)
liberator.focusContent(false); liberator.focusContent(false);
}, 0);
} }
} }
@@ -137,6 +131,8 @@ const modes = (function () //{{{
get all() mainModes.slice(), get all() mainModes.slice(),
get inputMode() main & (this.COMMAND_LINE | this.INPUT | this.TEXTAREA | this.COMPOSE),
addMode: function (name, extended, display) { addMode: function (name, extended, display) {
let disp = name.replace("_", " ", "g"); let disp = name.replace("_", " ", "g");
this[name] = 1 << lastMode++; this[name] = 1 << lastMode++;