[gtk+] [broadway] Report most special keys in keypressed
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] [broadway] Report most special keys in keypressed
- Date: Mon, 18 Apr 2011 17:18:53 +0000 (UTC)
commit 52074b4cac0c66900236baef705d27f6d6d55542
Author: Alexander Larsson <alexl redhat com>
Date: Mon Apr 18 10:49:47 2011 +0200
[broadway] Report most special keys in keypressed
Some special key keycode values as seen in keydown actually match
normal keys (like "." has a keyCode 46 on keyPress, which is the same
as Delete, but 190 for KeyDown). So we must match the special keys on
keypress. However, some things must be checked on keydown as they are not
generating keypress events.
gdk/broadway/broadway.js | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index d6fb43d..806ed76 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -2376,10 +2376,17 @@ var unicodeTable = {
0x28ff: 0x10028ff
};
+var ON_KEYDOWN = 1 << 0; /* Report on keydown, otherwise wait until keypress */
+
+
var specialKeyTable = {
- 8: 0xFF08, // BACKSPACE
- 13: 0xFF0D, // ENTER
- 9: 0xFF09, // TAB
+ // These generate a keyDown and keyPress in Firefox and Opera
+ 8: [0xFF08, ON_KEYDOWN], // BACKSPACE
+ 13: [0xFF0D, ON_KEYDOWN], // ENTER
+
+ // This generates a keyDown and keyPress in Opera
+ 9: [0xFF09, ON_KEYDOWN], // TAB
+
27: 0xFF1B, // ESCAPE
46: 0xFFFF, // DELETE
36: 0xFF50, // HOME
@@ -2420,10 +2427,16 @@ function getEventKeySym(ev) {
// with the key. The rest we pass on to keypress so we can get the
// translated keysym.
function getKeysymSpecial(ev) {
- // These are simple and risky to pass on to browser, handle directly
- if ((ev.keyCode in specialKeyTable))
- return specialKeyTable[ev.keyCode];
-
+ if (ev.keyCode in specialKeyTable) {
+ var r = specialKeyTable[ev.keyCode];
+ var flags = 0;
+ if (typeof r != 'number') {
+ flags = r[1];
+ r = r[0];
+ }
+ if (ev.type === 'keydown' || flags & ON_KEYDOWN)
+ return r;
+ }
// If we don't hold alt or ctrl, then we should be safe to pass
// on to keypressed and look at the translated data
if (!ev.ctrlKey && !ev.altKey)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]