From 5cc26f36173427a8a6e7be22aaa7db41bc4a5d89 Mon Sep 17 00:00:00 2001 From: "kyle.yuan%sun.com" Date: Fri, 17 May 2002 00:50:01 +0000 Subject: [PATCH] Bug 133365 Type letters to navigate XUL listbox Adde new event handler for keypress event git-svn-id: svn://10.0.0.236/trunk@121714 18797224-902f-48f8-a5cc-f745e15eee43 --- .../resources/content/bindings/listbox.xml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/mozilla/xpfe/global/resources/content/bindings/listbox.xml b/mozilla/xpfe/global/resources/content/bindings/listbox.xml index 698a642506a..974c20c42a8 100644 --- a/mozilla/xpfe/global/resources/content/bindings/listbox.xml +++ b/mozilla/xpfe/global/resources/content/bindings/listbox.xml @@ -34,6 +34,8 @@ null null null + 0 + "" + + @@ -635,6 +642,45 @@ this.currentItem.checked = !this.currentItem.checked; ]]> + + 0) { + var key = String.fromCharCode(event.charCode); + key = key.toLowerCase(); + if (event.timeStamp - this._lastKeyTime > 1000) + this._incrementalString = key; + else { + if (this._incrementalString.length != 1 || this._incrementalString.charAt(0) != key.charAt(0)) + this._incrementalString += key; + } + this._lastKeyTime = event.timeStamp; + + var l = this.selectedItems.length; + var c = -1; + if (l > 0) + c = this.getIndexOfItem(this.selectedItems[l-1]); + var rowCount = this.getRowCount(); + var start = 1; + + if (this._incrementalString.length > 1) + start = 0; + + for (var i = 0; i < rowCount; i++) { + var k = (i + start + c) % rowCount; + var item = this.getItemAtIndex(k); //listitem + var cellText = item.getAttribute("label"); + cellText = cellText.toLowerCase(); + if (cellText.search(this._incrementalString) == 0) { + this._isUpSelection=0; + this._isDownSelection=0; + this.ensureIndexIsVisible(k); + this.timedSelect(item, 500); + break; + } + } + } + ]]> +