Focus controller via XUL attributes.

git-svn-id: svn://10.0.0.236/trunk@181292 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mgalli%geckonnection.com 2005-09-30 18:35:53 +00:00
parent baaa4c106c
commit aacdfec758
2 changed files with 65 additions and 20 deletions

View File

@ -47,6 +47,7 @@ var gFullScreen=false;
var gRSSTag="minimo";
var gGlobalHistory = null;
var gURIFixup = null;
var gShowingMenuPopup=null;
function nsBrowserStatusHandler()
{
@ -267,20 +268,51 @@ function MiniNavStartup()
}
var gShowingMenuPopup=null;
/*
* Focus Shortcut Action. This is just a focus action dispatcher based on certain conditions
* defined in the XUL elements. Ideally would be interesting to have this as part of some new
* XUL elements that are based on existing XUL elements, or to incorporate, import, this behavior
* in the XUL declaration.
*/
function eventHandlerMenu(e) {
if( (e.keyCode==39 || e.keyCode==37) && (gShowingMenuPopup) ) {
BrowserMenuPopupFalse();
document.getElementById("back-button").focus();
}
if (e.keyCode == 112) {
document.getElementById("menu-button").focus();
var outnavTarget=document.commandDispatcher.focusedElement.getAttribute("accessrule");
if(outnavTarget!="" && e.keyCode==40 && !gShowingMenuPopup) {
ruleElement=findRuleById(document.getElementById(outnavTarget).getAttribute("accessnextrule"));
var tempElement=ruleElement.getAttribute("accessfocus");
if(tempElement=="#tabContainer") {
if(ruleElement.tabContainer) {
ruleElement.mTabContainer.childNodes[0].focus();
}
} else {
document.getElementById(tempElement).focus();
e.preventDefault();
}
}
/*
* We may use onblur with content navigation tabbrowser to snav enable disable.
*/
}
function findRuleById(outnavTarget) {
var ruleElement=document.getElementById(outnavTarget);
if(ruleElement.collapsed) {
return findRuleById(ruleElement.getAttribute("accessnextrule"));
} else {
return ruleElement;
}
}
/**
* Init stuff
*
@ -551,13 +583,17 @@ function BrowserScreenRotate()
function BrowserMenuPopup() {
document.getElementById("menu_MainPopup").showPopup(document.getElementById("menu-button"),-1,-1,"popup","bottomleft", "topleft");
gShowingMenuPopup=true;
}
function BrowserMenuPopupFalse() {
document.getElementById("menu_MainPopup").hidePopup();
gShowingMenuPopup=false;
}
function MenuPopupShowing() {
gShowingMenuPopup=true;
document.getElementById("menu-button").focus();
}
function MenuPopupHidden() {
gShowingMenuPopup=false;
}

View File

@ -86,12 +86,12 @@
<command id="cmd_DoBrowserRSS" oncommand="DoBrowserRSS()" />
<command id="cmd_BrowserMenu" oncommand="BrowserMenuPopup()" />
<toolbar id="nav-bar">
<toolbar id="nav-bar" accessfocus="menu-button" accessnextrule="toolbar-view" >
<toolbarbutton tabindex="1" id="menu-button" accesskey="m" command="cmd_BrowserMenu" />
<toolbarbutton tabindex="2" id="back-button" command="cmd_BrowserBack" />
<toolbarbutton tabindex="3" id="forward-button" command="cmd_BrowserForward" />
<toolbarbutton tabindex="4" id="reload-stop-button" class="reload-button" command="cmd_BrowserReload"/>
<toolbarbutton tabindex="1" accessrule="nav-bar" id="menu-button" accesskey="m" command="cmd_BrowserMenu" />
<toolbarbutton tabindex="2" accessrule="nav-bar" id="back-button" command="cmd_BrowserBack" />
<toolbarbutton tabindex="3" accessrule="nav-bar" id="forward-button" command="cmd_BrowserForward" />
<toolbarbutton tabindex="4" accessrule="nav-bar" id="reload-stop-button" class="reload-button" command="cmd_BrowserReload"/>
<textbox tabindex="5"
id="urlbar"
@ -108,7 +108,11 @@
</toolbar>
<toolbar id="toolbar-view" flex="1" collapsed="true" >
<toolbar id="toolbar-view" accessfocus="zoomplusitem"
accessnextrule="toolbar-rss"
flex="1"
collapsed="true" >
<groupbox flex="1" class="box-floatoptions">
<caption label="&zoom.label;"/>
<hbox flex="1" >
@ -116,18 +120,23 @@
<hbox flex="1" style="margin-top:4px ! important">
<label value="&zoomText.label;" />
<toolbarbutton class="button-border" command="cmd_BrowserZoomPlus" label="&zoomTextPlus.label;" />
<toolbarbutton class="button-border" command="cmd_BrowserZoomMinus" label="&zoomTextMinus.label;" />
<toolbarbutton tabindex="10" accessrule="toolbar-view" id="zoomplusitem" class="button-border" command="cmd_BrowserZoomPlus" label="&zoomTextPlus.label;" />
<toolbarbutton tabindex="11" accessrule="toolbar-view" class="button-border" command="cmd_BrowserZoomMinus" label="&zoomTextMinus.label;" />
</hbox>
</vbox>
<vbox>
<toolbarbutton class="button-close" width="10" height="10" align="top" flex="0" id="close-button" command="cmd_ViewOptions"/>
<toolbarbutton tabindex="12" accessrule="toolbar-view" class="button-close" width="10" height="10" align="top" flex="0" id="close-button" command="cmd_ViewOptions"/>
</vbox>
</hbox>
</groupbox>
</toolbar>
<toolbar id="toolbar-rss" flex="1" collapsed="true" >
<toolbar id="toolbar-rss"
accessfocus="toolbar-rss-rsstag"
accessnextrule="nav-bar"
flex="1"
collapsed="true" >
<groupbox flex="1" class="box-floatoptions">
<caption label="&rssBMtitle.label;"/>
<hbox flex="1" >
@ -135,11 +144,11 @@
<hbox flex="1" style="margin-top:4px ! important">
<label value="&rssText.label;" />
<textbox id="toolbar-rss-rsstag" flex="1" onchange="return DoBrowserRSS();"/>
<textbox tabindex="13" accessrule="toolbar-rss" id="toolbar-rss-rsstag" flex="1" onchange="return DoBrowserRSS();"/>
</hbox>
</vbox>
<vbox>
<toolbarbutton class="button-close" width="10" height="10" align="top" flex="0" id="close-button" command="cmd_ViewRSS"/>
<toolbarbutton tabindex="14" accessrule="toolbar-rss" class="button-close" width="10" height="10" align="top" flex="0" id="close-button" command="cmd_ViewRSS"/>
</vbox>
</hbox>
</groupbox>
@ -177,7 +186,7 @@
<menuitem id="menu_closeWindow" command="cmd_closeWindow" key="key_closeWindow" label="about" />
</popup>
<menupopup id="menu_MainPopup" onpopupshowing="MenuPopupShowing()">
<menupopup id="menu_MainPopup" onpopupshowing="MenuPopupShowing()" onpopuphidden="MenuPopupHidden()">
<menuitem id="command_BrowserOpenTab" command="cmd_BrowserOpenTab" label="New Tab" />
<!-- not working just yet.
<menuitem id="command_BrowserScreenRotate" command="cmd_BrowserScreenRotate" label="Rotate Screen" />