Closed
Bug 842013
Opened 12 years ago
Closed 12 years ago
keyup, keydown and keypress Event is not fired
Categories
(Firefox for Android Graveyard :: Keyboards and IME, defect)
Tracking
(firefox18 affected, firefox19 affected, firefox20 affected, firefox21 affected)
RESOLVED
FIXED
Firefox 22
People
(Reporter: info, Assigned: jchen)
Details
(Keywords: reproducible)
Attachments
(5 files, 2 obsolete files)
|
326 bytes,
text/HTML
|
Details | |
|
7.15 KB,
patch
|
cpeterson
:
review+
|
Details | Diff | Splinter Review |
|
5.34 KB,
patch
|
jchen
:
review+
|
Details | Diff | Splinter Review |
|
9.99 KB,
patch
|
cpeterson
:
review+
|
Details | Diff | Splinter Review |
|
10.42 KB,
patch
|
cpeterson
:
review+
|
Details | Diff | Splinter Review |
#1 Install/Launch Firefox for Android 18 (or beta 19).
#2 Open the testcase - it is simply a group of three inputs with key(up|down|press) events attached inline.
#3 Give focus to one of the inputs.
#4 Type something.
What happens:
The attached callback is not executed (the event is not fired) until you press enter (or backspace).
What should happen:
The attached callback should be executed at any keyboard up|down|press.
Updated•12 years ago
|
Attachment #714774 -
Attachment mime type: text/plain → text/HTML
Updated•12 years ago
|
Status: UNCONFIRMED → NEW
status-firefox18:
--- → affected
status-firefox19:
--- → affected
status-firefox20:
--- → affected
status-firefox21:
--- → affected
Ever confirmed: true
Flags: needinfo?(nchen)
Keywords: reproducible
| Assignee | ||
Comment 1•12 years ago
|
||
Virtual keyboards may not generate key events in many cases. Oftentimes, they perform more complex operations than simple key events allow: for example, if you press space to auto-correct a word, should a space key event be generated? Or key events corresponding to the corrected word?
The best way to detect changing input is to use the input event. For example,
> <input oninput="alert('on input');">
Flags: needinfo?(nchen)
| Assignee | ||
Updated•12 years ago
|
Assignee: nobody → nchen
Status: NEW → ASSIGNED
| Assignee | ||
Comment 2•12 years ago
|
||
This patch switches back to using key events for entering text outside of a composition.
There will be at least two more patches -- one to address an issue with duplicate key up events when using a hardware keyboard, and another to address unusual key mappings on Gingerbread devices involving certain characters like '<' and '>'.
Attachment #729765 -
Flags: review?(cpeterson)
| Assignee | ||
Comment 3•12 years ago
|
||
Editable can be used in many places, and we only want to suppress key up events during the key down handler.
Attachment #729768 -
Flags: review?(cpeterson)
Comment 4•12 years ago
|
||
Comment on attachment 729765 [details] [diff] [review]
Send key events for character input (v1)
Review of attachment 729765 [details] [diff] [review]:
-----------------------------------------------------------------
::: mobile/android/base/GeckoEditable.java
@@ +263,5 @@
> + KeyEvent [] keyEvents = mKeyMap.getEvents(
> + action.mSequence.toString().toCharArray());
> + if (keyEvents == null || keyEvents.length == 0) {
> + return false;
> + }
1. Please extract all the messy KeyCharacterMap.load() and mKeyMap.getEvents() code into a separate private helper method. Call it something like `KeyEvent[] synthesizeKeyEvents(String str)`.
2. Do we need to worry all the special cases we used to handle for Froyo and GB? Here is the old synthesizeKeyEvents() method:
https://hg.mozilla.org/mozilla-central/annotate/fda4bfed1a1b/mobile/android/base/GeckoInputConnection.java#l635
3. If we want to handle these cases, we should consider encapsulating all the KeyCharacterMap code and special cases into our own ("KeyMap"?) class.
Attachment #729765 -
Flags: review?(cpeterson) → feedback+
Comment 5•12 years ago
|
||
Comment on attachment 729768 [details] [diff] [review]
Suppress key up events during key down event (v1)
Review of attachment 729768 [details] [diff] [review]:
-----------------------------------------------------------------
ok
::: mobile/android/base/GeckoEditable.java
@@ +598,3 @@
> public Handler getInputConnectionHandler() {
> + // Can be called from either UI thread or IC thread;
> + // take must be taken to avoid race conditions
s/take/care/ ?
Attachment #729768 -
Flags: review?(cpeterson) → review+
| Assignee | ||
Comment 6•12 years ago
|
||
(In reply to Chris Peterson (:cpeterson) from comment #4)
> Comment on attachment 729765 [details] [diff] [review]
> Send key events for character input (v1)
>
> Review of attachment 729765 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: mobile/android/base/GeckoEditable.java
> @@ +263,5 @@
> > + KeyEvent [] keyEvents = mKeyMap.getEvents(
> > + action.mSequence.toString().toCharArray());
> > + if (keyEvents == null || keyEvents.length == 0) {
> > + return false;
> > + }
>
> 1. Please extract all the messy KeyCharacterMap.load() and
> mKeyMap.getEvents() code into a separate private helper method. Call it
> something like `KeyEvent[] synthesizeKeyEvents(String str)`.
Done
> 2. Do we need to worry all the special cases we used to handle for Froyo and
> GB? Here is the old synthesizeKeyEvents() method:
>
> https://hg.mozilla.org/mozilla-central/annotate/fda4bfed1a1b/mobile/android/
> base/GeckoInputConnection.java#l635
>
> 3. If we want to handle these cases, we should consider encapsulating all
> the KeyCharacterMap code and special cases into our own ("KeyMap"?) class.
I'm going to post another patch that makes the special cases unnecessary.
Attachment #729765 -
Attachment is obsolete: true
Attachment #730239 -
Flags: review?(cpeterson)
| Assignee | ||
Comment 7•12 years ago
|
||
Addressed review comment
Attachment #729768 -
Attachment is obsolete: true
Attachment #730240 -
Flags: review+
| Assignee | ||
Comment 8•12 years ago
|
||
Basically some special characters didn't work on Gingerbread because they had extra modifiers like Ctrl added. This patch makes us not add modifiers to a key press if the character already has modifiers applied.
Attachment #730242 -
Flags: review?(cpeterson)
Comment 9•12 years ago
|
||
Comment on attachment 730239 [details] [diff] [review]
Send key events for character input (v2)
Review of attachment 730239 [details] [diff] [review]:
-----------------------------------------------------------------
LGTM!
Attachment #730239 -
Flags: review?(cpeterson) → review+
| Assignee | ||
Comment 10•12 years ago
|
||
I found a bug using the testcase in attachment 714774 [details]
Because we are sending key events one-by-one, if there's a window.alert() in the event handler, the events could end up being processed out-of-order. Seems to me like the best solution is to bunch up the key events in Gecko and dispatch them all at once.
| Assignee | ||
Comment 11•12 years ago
|
||
This patch creates a new Gecko event type - IME_KEY_EVENT, which is exactly the same as KEY_EVENT, except these new events are saved in an array until the next IME_REPLACE_TEXT event, which dispatches these events instead of the normal composition events. This ensures that the IME key events are processed in-order.
Attachment #730436 -
Flags: review?(cpeterson)
Comment 12•12 years ago
|
||
Comment on attachment 730242 [details] [diff] [review]
Don't add extra modifiers to key press events (v1)
Review of attachment 730242 [details] [diff] [review]:
-----------------------------------------------------------------
LGTM
Attachment #730242 -
Flags: review?(cpeterson) → review+
Comment 13•12 years ago
|
||
Comment on attachment 730436 [details] [diff] [review]
Buffer IME key events and dispatch them at once (v1)
Review of attachment 730436 [details] [diff] [review]:
-----------------------------------------------------------------
LGTM
::: mobile/android/base/GeckoEditable.java
@@ +284,2 @@
> }
> + return;
You don't need this return;
::: widget/android/nsWindow.cpp
@@ +877,5 @@
> break;
>
> + case AndroidGeckoEvent::IME_KEY_EVENT:
> + if (win->mFocus) {
> + win->mFocus->mIMEKeyEvents.AppendElement(*ae);
Maybe add a short comment that these IME key events are batched up until IME_REPLACE_TEXT.
Attachment #730436 -
Flags: review?(cpeterson) → review+
| Assignee | ||
Comment 14•12 years ago
|
||
Addressed review comments.
https://hg.mozilla.org/integration/mozilla-inbound/rev/154de20f3148
https://hg.mozilla.org/integration/mozilla-inbound/rev/fccb21a4fada
https://hg.mozilla.org/integration/mozilla-inbound/rev/d8d5b906ca42
https://hg.mozilla.org/integration/mozilla-inbound/rev/95c1cfb26fda
Target Milestone: --- → Firefox 22
Comment 15•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/154de20f3148
https://hg.mozilla.org/mozilla-central/rev/fccb21a4fada
https://hg.mozilla.org/mozilla-central/rev/d8d5b906ca42
https://hg.mozilla.org/mozilla-central/rev/95c1cfb26fda
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Updated•4 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•