- Make arrow keys toggle focus between controls.

- Make quicksearch in history case insensitive.
- Port over some trunk fixes.
This commit is contained in:
blakeross%telocity.com 2002-11-11 01:51:50 +00:00
parent 4a6f3be6b9
commit 3247f4ea44
9 changed files with 141 additions and 29 deletions

View File

@ -3783,8 +3783,7 @@ nsGlobalHistory::RowMatches(nsIMdbRow *aRow,
NS_ConvertUCS2toUTF8 utf8Value(term->text);
if (term->method.Equals("is")) {
if (utf8Value != rowVal)
if (!utf8Value.Equals(rowVal, nsCaseInsensitiveCStringComparator()))
return PR_FALSE;
}
@ -3794,12 +3793,12 @@ nsGlobalHistory::RowMatches(nsIMdbRow *aRow,
}
else if (term->method.Equals("contains")) {
if (!FindInReadable(utf8Value, start, end))
if (!FindInReadable(utf8Value, start, end, nsCaseInsensitiveCStringComparator()))
return PR_FALSE;
}
else if (term->method.Equals("doesntcontain")) {
if (FindInReadable(utf8Value, start, end))
if (FindInReadable(utf8Value, start, end, nsCaseInsensitiveCStringComparator()))
return PR_FALSE;
}
@ -3807,7 +3806,7 @@ nsGlobalHistory::RowMatches(nsIMdbRow *aRow,
// need to make sure that the found string is
// at the beginning of the string
nsACString::const_iterator real_start = start;
if (!(FindInReadable(utf8Value, start, end) &&
if (!(FindInReadable(utf8Value, start, end, nsCaseInsensitiveCStringComparator()) &&
real_start == start))
return PR_FALSE;
}
@ -3816,7 +3815,7 @@ nsGlobalHistory::RowMatches(nsIMdbRow *aRow,
// need to make sure that the found string ends
// at the end of the string
nsACString::const_iterator real_end = end;
if (!(RFindInReadable(utf8Value, start, end) &&
if (!(RFindInReadable(utf8Value, start, end, nsCaseInsensitiveCStringComparator()) &&
real_end == end))
return PR_FALSE;
}

View File

@ -69,6 +69,40 @@
<property name="autoCheck"
onget="return this.getAttribute('autoCheck') == 'true';"
onset="this.setAttribute('autoCheck', val); return val;"/>
<method name ="filterButtons">
<parameter name="node"/>
<body>
<![CDATA[
if (node.localName == "button" && node.accessKey &&
!node.disabled && !node.collapsed && !node.hidden)
return NodeFilter.FILTER_ACCEPT;
return NodeFilter.FILTER_SKIP;
]]>
</body>
</method>
<method name="fireAccessKeyButton">
<parameter name="aSubtree"/>
<parameter name="aAccessKeyLower"/>
<body>
<![CDATA[
var iterator = aSubtree.ownerDocument.createTreeWalker(aSubtree,
NodeFilter.SHOW_ELEMENT,
this.filterButtons, false);
while (iterator.nextNode()) {
var test = iterator.currentNode;
if (test.accessKey.toLowerCase() == aAccessKeyLower &&
!test.disabled && !test.collapsed && !test.hidden) {
test.focus();
test.click();
return true;
}
}
return false;
]]>
</body>
</method>
</implementation>
<handlers>
@ -84,11 +118,51 @@
]]>
</handler>
<handler event="keypress">
<![CDATA[
if (event.keyCode == KeyEvent.DOM_VK_UP ||
event.keyCode == KeyEvent.DOM_VK_LEFT)
return window.document.commandDispatcher.rewindFocus();
if (event.keyCode == KeyEvent.DOM_VK_DOWN ||
event.keyCode == KeyEvent.DOM_VK_RIGHT)
return window.document.commandDispatcher.advanceFocus();
if (event.keyCode || event.charCode <= ' ')
return; // No arrow key or potential accesskey pressed
// Possible accesskey pressed
var charPressedLower = String.fromCharCode(event.charCode).toLowerCase();
// If the accesskey of the current button is pressed, just activate it
if (this.accessKey.toLowerCase() == charPressedLower) {
this.click();
return;
}
// Search for accesskey in the list of buttons for this doc and each subdoc
// Get the buttons for the main document and all sub-frames
for (var frameCount = -1; frameCount < window.top.frames.length; frameCount++) {
var doc = (frameCount == -1)? window.top.document:
window.top.frames[frameCount].document
if (this.fireAccessKeyButton(doc.documentElement, charPressedLower))
return;
}
// Test anonymous buttons
var dlg = window.top.document;
var buttonBox = dlg.getAnonymousElementByAttribute(dlg.documentElement,
"anonid", "buttons");
if (buttonBox)
this.fireAccessKeyButton(buttonBox, charPressedLower);
]]>
</handler>
</handlers>
</binding>
<binding id="button" display="xul:button"
extends="chrome://global/content/widgets/button.xml#button-base">
extends="chrome://global/content/bindings/button.xml#button-base">
<resources>
<stylesheet src="chrome://global/skin/button.css"/>
</resources>
@ -106,7 +180,7 @@
</binding>
<binding id="menu" display="xul:menu"
extends="chrome://global/content/widgets/button.xml#button">
extends="chrome://global/content/bindings/button.xml#button">
<content>
<children includes="observes|template|menupopup|tooltip"/>
<xul:hbox class="box-inherit button-box" xbl:inherits="align,dir,pack,orient"
@ -121,7 +195,7 @@
</binding>
<binding id="menu-button-base"
extends="chrome://global/content/widgets/button.xml#button-base">
extends="chrome://global/content/bindings/button.xml#button-base">
<implementation>
<constructor>
this.init();
@ -223,7 +297,7 @@
</binding>
<binding id="menu-button" display="xul:menu"
extends="chrome://global/content/widgets/button.xml#menu-button-base">
extends="chrome://global/content/bindings/button.xml#menu-button-base">
<resources>
<stylesheet src="chrome://global/skin/button.css"/>
</resources>
@ -241,7 +315,7 @@
</binding>
<binding id="button-image" display="xul:button"
extends="chrome://global/content/widgets/button.xml#button">
extends="chrome://global/content/bindings/button.xml#button">
<content>
<xul:image class="button-image-icon" xbl:inherits="src=image"/>
</content>

View File

@ -29,14 +29,28 @@
]]>
</getter>
</property>
<method name="setChecked">
<parameter name="aValue"/>
<body>
<![CDATA[
var change = (aValue != (this.getAttribute('checked') == 'true'));
if (aValue)
this.setAttribute('checked', 'true');
else
this.removeAttribute('checked');
if (change) {
var event = document.createEvent('Events');
event.initEvent('CheckboxStateChange', false, true);
this.dispatchEvent(event);
}
return aValue;
]]>
</body>
</method>
<!-- public implementation -->
<property name="checked" onset="if (val) this.setAttribute('checked', 'true');
else this.removeAttribute('checked');
var event = document.createEvent('Events');
event.initEvent('CheckboxStateChange', false, true);
this.dispatchEvent(event);
return val;"
<property name="checked" onset="return this.setChecked(val);"
onget="return this.getAttribute('checked') == 'true';"/>
</implementation>

View File

@ -17,7 +17,7 @@
<children/>
</xul:vbox>
<xul:hbox class="dialog-button-box" pack="end"
<xul:hbox class="dialog-button-box" pack="end" anonid="buttons"
xbl:inherits="pack=buttonpack,align=buttonalign,dir=buttondir,orient=buttonorient">
<xul:button dlgtype="accept" class="dialog-button"/>
<xul:button dlgtype="extra1" class="dialog-button" hidden="true" label=""/>
@ -187,8 +187,12 @@
var button = buttons[dlgtype];
buttons[dlgtype].addEventListener("command", this._handleButtonCommand, true);
// don't override custom labels with pre-defined labels on explicit buttons
if (!button.hasAttribute("label"))
if (!button.hasAttribute("label")) {
button.setAttribute("label", this.mStrBundle.GetStringFromName("button-"+dlgtype));
var accessKey = this.mStrBundle.GetStringFromName("accesskey-"+dlgtype);
if (accessKey)
button.setAttribute("accesskey", accessKey);
}
}
// ensure that hitting enter triggers ondialogaccept

View File

@ -22,10 +22,11 @@
<property name="accessible">
<getter>
<![CDATA[
if (this.localName == "popup" || this.localName == "menupopup") {
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
if (this.localName == "popup" || this.localName == "menupopup")
return (this.parentNode.localName == "menulist")? accService.createXULSelectListAccessible(this): accService.createXULMenupopupAccessible(this);
}
else if (this.localName == "tooltip")
return accService.createXULTooltipAccessible(this);
return null;
]]>
</getter>

View File

@ -56,8 +56,12 @@
</getter>
<setter>
<![CDATA[
if (this.getAttribute("focused") == "true")
var alreadySelected = val.getAttribute("selected") == "true";
var focused = false;
if (this.getAttribute("focused") == "true") {
val.setAttribute("focused", "true");
focused = true;
}
val.setAttribute("selected", "true");
this.value = val.value;
@ -70,13 +74,16 @@
children[i].removeAttribute("focused");
}
}
var event = document.createEvent("Events");
var event = document.createEvent("Events");
event.initEvent("select", false, true);
this.dispatchEvent(event);
var myEvent = document.createEvent("Events");
myEvent.initEvent("RadioStateChange", true, true);
val.dispatchEvent(myEvent);
if (!alreadySelected && focused) {
// Only report if actual change
var myEvent = document.createEvent("Events");
myEvent.initEvent("RadioStateChange", true, true);
val.dispatchEvent(myEvent);
}
return val;
]]>

View File

@ -20,7 +20,7 @@
<xul:hbox class="textbox-input-box" flex="1">
<children/>
<html:input class="textbox-input" flex="1" anonid="input"
xbl:inherits="onfocus,onblur,value,type,maxlength,disabled,size,readonly,tabindex"/>
xbl:inherits="onfocus,onblur,value,type,maxlength,disabled,size,readonly,tabindex,accesskey"/>
</xul:hbox>
</content>

View File

@ -9,6 +9,19 @@
<resources>
<stylesheet src="chrome://global/skin/toolbar.css"/>
</resources>
<implementation implements="nsIAccessibleProvider">
<property name="accessible">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
if (this.localName == "toolbarseparator")
return accService.createXULToolbarSeparatorAccessible(this);
else
return accService.createXULToolbarAccessible(this);
]]>
</getter>
</property>
</implementation>
</binding>
<binding id="toolbox" extends="chrome://global/content/widgets/toolbar.xml#toolbar-base">

View File

@ -371,7 +371,7 @@ column {
/******** listbox **********/
listbox {
-moz-binding: url("chrome://global/content/bindings/listbox.xml#listbox");
-moz-binding: url("chrome://global/content/widgets/listbox.xml#listbox");
}
listcols, listcol {