Closed Bug 675913 Opened 13 years ago Closed 11 years ago

event is not the event you expect on widget click

Categories

(Add-on SDK Graveyard :: Documentation, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: noitidart, Assigned: jsantell)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Build ID: 20110615151330

Steps to reproduce:

https://builder.addons.mozilla.org/addon/1012299/latest/


Actual results:

When you click on the widget event does not hold stuff like event.button (please see the console for the dump of event properties)

event holds this:
info: bstr:
on=function on() {
    [native code]
}
once=function once() {
    [native code]
}
removeListener=function removeListener() {
    [native code]
}
port=[object Trait]
postMessage=function WidgetView_postMessage() {
    [native code]
}
destroy=function WidgetView_destroy() {
    [native code]
}
label=Copy urls of current tabs to clipboard
id=widgetID1
tooltip=Copy urls of current tabs to clipboard
width=16
content=undefined
panel=undefined
contentURL=http://www.mozilla.org/favicon.ico
contentScriptFile=null
contentScript=null
contentScriptWhen=end




Expected results:

it should hold stuff like event.button
Component: Add-on Builder → General
Product: addons.mozilla.org → Add-on SDK
QA Contact: add-on-builder → general
The widget doc doesn't say this (it should), but the object passed to your click listener is the widget that was clicked, not some event.  Why did you think it would be an event?
Morphing this bug to be about making the widget doc clearer.
Status: UNCONFIRMED → NEW
Component: General → Documentation
Ever confirmed: true
Priority: -- → P3
QA Contact: general → documentation
Target Milestone: --- → 1.1
(Pushing all open bugs to the --- milestone for the new triage system)
Target Milestone: 1.1 → ---
Assignee: nobody → jsantell
Attached file Pointer to GH PR 846
Attachment #722893 - Flags: review?(rFobic)
Comment on attachment 722893 [details]
Pointer to GH PR 846

I'm also good reviewer for widget as I did the last big work on this module (the widgetview support).

Your patch looks good, you may want to also modify the second occurance of click event, the one specific to WidgetView in order to say that it receive an event object instead.
Attachment #722893 - Flags: review?(rFobic) → review+
Thanks Alex! In the case of WidgetView's click handler arguments, it receives a `null`.

WidgetView.on('click', function (e) {
  // e is null
});

Scoping it out
After discussing with Alex, the WidgetView's click handler arguments is intentionally null: https://github.com/mozilla/addon-sdk/blob/master/lib/sdk/widget.js#L850
Commit pushed to master at https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/c78c30999a1de613deb10a0a720ad4055cb2526e
Merge pull request #846 from jsantell/widget-click-docs-675913

Fix Bug 675913: Clarify argument in widget click handler, a=@ochameau
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: