Bug 1356641 - Ctrl+click location item loads wrong URL. r?mak
With ideas and code from Oriol <oriol-bugzilla@hotmail.com>.
MozReview-Commit-ID: CjuCAkYaort
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -2488,16 +2488,55 @@ extends="chrome://global/content/binding
url: params,
}
}
return action;
]]></body>
</method>
</implementation>
+
+ <handlers>
+ <!--
+ This overrides listitem's mousedown handler because we want to set the
+ selected item even when the shift or accel keys are pressed.
+ -->
+ <handler event="mousedown"><![CDATA[
+ // Call this.control only once since it's not a simple getter.
+ let control = this.control;
+ if (!control || control.disabled) {
+ return;
+ }
+ if (!this.selected) {
+ control.selectItem(this);
+ }
+ control.currentItem = this;
+ ]]></handler>
+
+ <handler event="mouseover"><![CDATA[
+ // The point of implementing this handler is to allow drags to change
+ // the selected item. If the user mouses down on an item, it becomes
+ // selected. If they then drag the mouse to another item, select it.
+ // Handle all three primary mouse buttons: right, left, and wheel, since
+ // all three change the selection on mousedown.
+ let mouseDown = event.buttons & 0b111;
+ if (!mouseDown) {
+ return;
+ }
+ // Call this.control only once since it's not a simple getter.
+ let control = this.control;
+ if (!control || control.disabled) {
+ return;
+ }
+ if (!this.selected) {
+ control.selectItem(this);
+ }
+ control.currentItem = this;
+ ]]></handler>
+ </handlers>
</binding>
<binding id="autocomplete-tree" extends="chrome://global/content/bindings/tree.xml#tree">
<content>
<children includes="treecols"/>
<xul:treerows class="autocomplete-treerows tree-rows" xbl:inherits="hidescrollbar" flex="1">
<children/>
</xul:treerows>