diff options
author | thomascube <thomas@roundcube.net> | 2008-08-22 10:37:48 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2008-08-22 10:37:48 +0000 |
commit | 26f5b0935ef4d8bc01e2b8581f7d7ed3c4508fc2 (patch) | |
tree | 2c5c1388631779ec04234200532aed74bc1b5775 /program/js/list.js | |
parent | 0ced2b9ac03e425750a76dea3ed59156b2709b4c (diff) |
Fix keyboard control of the list widgets and prevent Safari from scrolling (#1485279)
Diffstat (limited to 'program/js/list.js')
-rw-r--r-- | program/js/list.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/program/js/list.js b/program/js/list.js index a163f55ba..a83a8af6f 100644 --- a/program/js/list.js +++ b/program/js/list.js @@ -86,8 +86,10 @@ init: function() this.frame = this.list.parentNode; // set body events - if (this.keyboard) - rcube_event.add_listener({element:document, event:'keypress', object:this, method:'key_press'}); + if (this.keyboard) { + rcube_event.add_listener({element:document, event:'keyup', object:this, method:'key_press'}); + rcube_event.add_listener({element:document, event:'keydown', object:rcube_event, method:'cancel'}); + } } }, @@ -548,20 +550,20 @@ highlight_row: function(id, multiple) */ key_press: function(e) { - if (this.focused != true) + if (this.focused != true) return true; - var keyCode = document.layers ? e.which : document.all ? event.keyCode : document.getElementById ? e.keyCode : 0; + var keyCode = rcube_event.get_keycode(e); var mod_key = rcube_event.get_modifier(e); switch (keyCode) { case 40: case 38: - case 63233: // "down", in safari keypress - case 63232: // "up", in safari keypress + case 63233: // "down", in safari keypress + case 63232: // "up", in safari keypress + // Stop propagation so that the browser doesn't scroll + rcube_event.cancel(e); return this.use_arrow_key(keyCode, mod_key); - break; - default: this.shiftkey = e.shiftKey; this.key_pressed = keyCode; |