Google Groups Home
Help | Sign in
Mozilla DialogBox.onKeyPressPreview() broken in 1.1?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
lpodmolik@gmail.com  
View profile
 More options Aug 14 2006, 5:09 pm
From: "lpodmo...@gmail.com" <lpodmo...@gmail.com>
Date: Mon, 14 Aug 2006 14:09:23 -0700
Local: Mon, Aug 14 2006 5:09 pm
Subject: Mozilla DialogBox.onKeyPressPreview() broken in 1.1?
I have code like the following in a DialogBox subclass that dismisses a
dialog box when the user presses the Escape key:

public boolean onKeyPressPreview(char key, int modifiers) {
    if (key == 033) {  // ESC
        hide();
        return false;
    }
    return true;    // propagate event

}

This code worked in all browsers in 1.0.21.  In 1.1, it still works in
hosted mode and in IE, but does not work in Firefox.  Looking more
closely, the reason is that in Firefox the value of key is 0 when
Escape is pressed.  Interestingly, the value is not always 0 -- most
key codes get sent correctly, but so far I've seen that ESC and tab
result in key being 0.  Is this a known issue?  As I mentioned, this
worked fine in 1.0.21.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mat Gessel  
View profile
 More options Aug 14 2006, 7:49 pm
From: "Mat Gessel" <mat.ges...@gmail.com>
Date: Mon, 14 Aug 2006 16:49:25 -0700
Local: Mon, Aug 14 2006 7:49 pm
Subject: Re: Mozilla DialogBox.onKeyPressPreview() broken in 1.1?
Looks like a side-effect of the DOM.eventGetKeyCode() fix. In 1.1, IE
still reads evt.keyCode, but the other browsers were changed to read
evt.which.

You can see which keycodes are available for which events here:
http://www.asquare.net/javascript/tests/KeyCode.html

To trap non-character keys I'd use the keydown or keyup methods. The
alpha keycodes returned in keydown and keyup are usually capitalized
so I do a Character.toUpperCase((char) keycode) when I need to compare
to them.

--
Mat Gessel
http://www.asquare.net

On 8/14/06, lpodmo...@gmail.com <lpodmo...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google