Closed Bug 721512 Opened 8 years ago Closed 7 years ago

Widgets: Use EventUtils sendChar() and sendKey(), instead of calling synthesizeKey() directly

Categories

(Toolkit :: XUL Widgets, defect, minor)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: karun.84, Assigned: marioalv)

References

()

Details

Attachments

(1 file, 1 obsolete file)

Referencing bug Bug 720087, Use EventUtils sendChar() and sendKey(), instead of calling synthesizeKey() directly.
Summary: Use EventUtils sendChar() and sendKey(), instead of calling synthesizeKey() directly → Widgets: Use EventUtils sendChar() and sendKey(), instead of calling synthesizeKey() directly
No longer blocks: 721516
Assignee: nobody → karun.84
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Version: unspecified → Trunk
Assignee: karun.84 → nobody
Status: ASSIGNED → NEW
Assignee: nobody → marioalv.mozilla
Hi everyone.
I'm going to work on this bug.

I've been checking the code to be changed and spotted some replacement scenarios.
Also, I noticed that the function EventUtils.sendKey used in bugs related to this one takes only two parameters.
I'm using this bug as an example: https://bugzilla.mozilla.org/show_bug.cgi?id=721495

Here's the patch:
https://bugzilla.mozilla.org/attachment.cgi?id=591941&action=diff

Where is this EventUtils.sendKey definition?
Is it this one? http://mxr.mozilla.org/mozilla-central/source/testing/mochitest/tests/SimpleTest/EventUtils.js#116 

These are the replacement scenarios, according to the examples:
1.
{ synthesizeKey("VK_DOWN", { }); },

converts to:
{ sendKey("DOWN"); },


2. 
synthesizeKey("VK_RETURN", { }, win);

converts to:
{ sendKey("RETURN", win); },

3. 
{ synthesizeKey("V", { altKey: true }); },

converts to? I suppose the function stays the same.

4.
{ synthesizeKey("V", { altKey: true }, win); },

converts to? I suppose the function stays the same.

I was curious about why we are using that function definition with two parameters, which will prevent us to change scenarios 3 and 4.

Thanks.
This is my first approach to solve this bug. 
I changed the calls to synthesizeKey() for calls to sendKey() and sendChar() where possible. 
Please let me know if some corrections need to be made.
Thanks.
Attachment #665621 - Flags: review?(sgautherie.bz)
Hi! I don't think Serge isn't a toolkit peer. This page has a list of toolkit peers you could use: https://wiki.mozilla.org/Modules/Toolkit
Attachment #665621 - Flags: review?(sgautherie.bz) → review?(dao)
Attachment #665621 - Flags: review?(dao) → review?(enndeakin)
> +  test: function() { sendChar("H");; },

This line has two semicolons. Remove one of them.

In all the cases where sendChar is called, you should call it with the lowercase letter for the key. For example use sendChar("h") which sends the 'h' key instead of sendChar("H") which sends shift+h and could have otherwise lead to subtly differently behaviour.
Hi.
Thanks for your review. 
I've made the changes you suggested. Please let me know if I need to change something else.

Thanks.
Attachment #665621 - Attachment is obsolete: true
Attachment #665621 - Flags: review?(enndeakin)
Attachment #672345 - Flags: review?(enndeakin)
Attachment #672345 - Flags: review?(enndeakin) → review+
https://hg.mozilla.org/mozilla-central/rev/ab8ef7a28e2e
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
You need to log in before you can comment on or make changes to this bug.