Closed Bug 409714 Opened 17 years ago Closed 17 years ago

FF3.0 change - onpopupshowing event.clientX/Y is always 0

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 306202

People

(Reporter: tommut, Unassigned)

Details

(Keywords: regression)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b2) Gecko/2007121120 Firefox/3.0b2 In my extension I have a xul tree, and inside of the tree's tooltip onpopupshowing function I have code that I use to detect which row is currently hovered over in the tree (in order to dynamically show an appropriate tooltip based on the selected item). This code works in FF2.0 where my onpopupshowing event always has the correct clientX and clientY values. But in FF3.0 this code always gets 0,0 for those values. Here's my tree with a tooltip that calls a function on onpopupshowing: <tree id="reminderTree"> <popupset> <tooltip onpopupshowing="return reminderTreeTooltip(event);"> . . . . . . And the function: function reminderTreeTooltip(event) { dump( "event: " + event.clientX + " -- " + event.clientY + "\n") } That always prints out 0 -- 0 in FF3, and prints out the appropriate coordinates in FF2. Is there some change that I need to react to in FF3? Or maybe there is a better way to do this. I am using those values to get the current hovered index via: var index = tree.boxObject.getRowAt( event.clientX, event.clientY ); I was pointed to an old resolved bug that was similar as well: https://bugzilla.mozilla.org/show_bug.cgi?id=306202#c4 Reproducible: Always
Component: Extension Compatibility → Event Handling
Keywords: regression
Product: Firefox → Core
QA Contact: extension.compatibility → events
Version: unspecified → Trunk
It would be great if you attached a simple testcase. BTW the reason I pointed to that comment was that you can't always rely on clientX to get the selected item in onpopupshowing.
Thanks for the info. Do you happen to know if there's another (reliable) way to get the hovered-over index for a popup? If this mechanism can't be guaranteed (though it seemed to always work in FF2), then I should probably do whatever the best practice is, even if it's more complex.
The code for Places Organizer (now Library - see PlacesController.prototype._buildSelectionMetadata) uses view.selection to get selected nodes and operates on them. This looks like it should work for both invokation via keyboard and invokation using mouse. I think it's still important to figure out if the breakage here was intended (and if it can be fixed for Fx3), so if you have a testcase or have time to create one, please attach it here.
Ok, I'll check out the view.selection. Thanks. As for the testcase, it is basically the one I had in the summary. A tree is defined in a xul file: <tree id="reminderTree"> <popupset> <tooltip onpopupshowing="return reminderTreeTooltip(event);"/> </popupset> </tree> And the function: function reminderTreeTooltip(event) { dump( "event: " + event.clientX + " -- " + event.clientY + "\n") } Or you can see it in the reminderfox extension: https://addons.mozilla.org/en-US/firefox/addon/1191 If you hover over a reminder event in the tree list -- in FF2.x, you'll see the tooltip. But in FF3.0 you do not.
Actually now that I think about it, view.selection is used to get selected nodes, which isn't what I'm after here. I need to get the hovered-over node, which could be completely different from the selected node. So I'm not sure if there is a way to do that other than using the clientX/Y. (In reply to comment #3)
er, I was thinking of the context menu. I don't understand why a popupshowing event would have mouse coords (clientX/Y) in it in any other case.
Oh sorry, this scenario is dealing with tooltips. Essentially I am trying to get the tree item that the tooltip popup has shown on. I am using the event's mouse coordinates to figure this out (which I got from some mozilla examples on the web some time ago). Here's the actual function logic that uses the coordinates to get the tree index that is currently hovered on: function reminderTreeTooltip(event) { var tree = document.getElementById("reminderTree"); var boxobject = tree.boxObject; boxobject.QueryInterface(Components.interfaces.nsITreeBoxObject); var row = {}, column = {}, part = {}; boxobject.getCellAt(event.clientX, event.clientY, row, column, part); var index = tree.boxObject.getRowAt( event.clientX, event.clientY ); var treeChildren = document.getElementById("treechildren"); var selectedTreeItem = treeChildren.childNodes[index]; var reminderRefId = selectedTreeItem.childNodes[0].getAttribute(REMINDER_ID_REF); // show the correct tooltip information based on the selected item }
Duping to bug 306202 which has been reopened.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.