Focusing urlbar should select contents (37587). r=brade sr=ben

This commit is contained in:
blakeross%telocity.com 2006-09-14 05:58:58 +00:00
parent 5012b30ed0
commit f7826d0a15
2 changed files with 9 additions and 7 deletions

View File

@ -31,6 +31,7 @@ var gBrandBundle;
var gNavigatorRegionBundle;
var gBrandRegionBundle;
var gLastValidURL = "";
var gClickSelectsAll = -1;
var pref = Components.classes["@mozilla.org/preferences;1"]
.getService(Components.interfaces.nsIPref);
@ -1303,18 +1304,20 @@ function getNewThemes()
loadURI(gBrandRegionBundle.getString("getNewThemesURL"));
}
function URLBarMouseupHandler(aEvent)
function URLBarFocusHandler(aEvent)
{
if (aEvent.button == 0 && pref.GetBoolPref("browser.urlbar.clickSelectsAll")) {
var selectionLen = gURLBar.selectionEnd - gURLBar.selectionStart;
if (selectionLen == 0)
if (gURLBar) {
if (gClickSelectsAll == -1)
gClickSelectsAll = pref.GetBoolPref("browser.urlbar.clickSelectsAll");
if (gClickSelectsAll)
gURLBar.setSelectionRange(0, gURLBar.textLength);
}
}
function URLBarBlurHandler(aEvent)
{
if (pref.GetBoolPref("browser.urlbar.clickSelectsAll"))
// XXX why the hell do we have to do this?
if (gClickSelectsAll)
gURLBar.setSelectionRange(0, 0);
}

View File

@ -164,8 +164,7 @@ Contributor(s): ______________________________________. -->
tooltip="aTooltip" tooltiptext="&locationBar.tooltip;"
ontextcommand="return handleURLBarCommand(userAction);"
ontextrevert="return handleURLBarRevert();"
onmouseup="URLBarMouseupHandler(event);"
onkeyup="URLBarKeyupHandler(event);"
onfocus="URLBarFocusHandler(event);"
onblur="URLBarBlurHandler(event);">
<image id="page-proxy-button" allowevents="true"
ondraggesture="PageProxyDragGesture(event);"/>