Updating urlbar to select all on the first click.

This commit is contained in:
dougt%meer.net 2005-12-08 20:07:13 +00:00
Родитель bd4d91f4d4
Коммит 7dbed7255a
2 изменённых файлов: 31 добавлений и 5 удалений

Просмотреть файл

@ -41,6 +41,9 @@ const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
var gBookmarksDoc=null; var gBookmarksDoc=null;
var gURLBar = null; var gURLBar = null;
var gClickSelectsAll = true;
var gIgnoreFocus = false;
var gIgnoreClick = false;
var gBrowserStatusHandler; var gBrowserStatusHandler;
var gSelectedTab=null; var gSelectedTab=null;
var gFullScreen=false; var gFullScreen=false;
@ -239,6 +242,8 @@ function MiniNavStartup()
try { try {
gURLBar = document.getElementById("urlbar"); gURLBar = document.getElementById("urlbar");
gURLBar.setAttribute("completedefaultindex", "true");
var currentTab=getBrowser().selectedTab; var currentTab=getBrowser().selectedTab;
browserInit(currentTab); browserInit(currentTab);
gSelectedTab=currentTab; gSelectedTab=currentTab;
@ -1076,11 +1081,31 @@ function URLBarEntered()
return true; return true;
} }
function URLBarFocusHandler()
function URLBarFocusHandler(aEvent, aElt)
{ {
if (gIgnoreFocus)
gIgnoreFocus = false;
else if (gClickSelectsAll)
aElt.select();
gURLBar.setAttribute("open", "true");
gURLBar.showHistoryPopup(); gURLBar.showHistoryPopup();
} }
function URLBarMouseDownHandler(aEvent, aElt)
{
gIgnoreFocus = true;
gIgnoreClick = false;
aElt.setSelectionRange(0, 0);
}
function URLBarClickHandler(aEvent, aElt)
{
if (!gIgnoreClick && aElt.selectionStart == aElt.selectionEnd)
aElt.select();
}
var gRotationDirection = true; var gRotationDirection = true;
function BrowserScreenRotate() function BrowserScreenRotate()

Просмотреть файл

@ -132,15 +132,16 @@
<textbox tabindex="5" <textbox tabindex="5"
id="urlbar" id="urlbar"
flex="100%" flex="1"
type="autocomplete" type="autocomplete"
enablehistory="true" enablehistory="true"
autocompletesearch="history" autocompletesearch="history"
completeselectedindex="true" completeselectedindex="true"
autocompletepopup="PopupAutoComplete" autocompletepopup="PopupAutoComplete"
onfocus="URLBarFocusHandler();" ontextentered="return URLBarEntered();"
ontextentered="return URLBarEntered();"> onfocus="URLBarFocusHandler(event, this);"
onmousedown="URLBarMouseDownHandler(event, this);"
onclick="URLBarClickHandler(event, this);">
<deck id='proxy-deck'> <deck id='proxy-deck'>
<image id="urlbar-deck" /> <image id="urlbar-deck" />
</deck> </deck>