Bug 18357

Summary: [GTK] Enter on buttons doesn't work
Product: WebKit Reporter: Marco Barisione <marco.barisione>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: alp, ap
Priority: P3    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Attachments:
Description Flags
Set the text of the event to '\r' when the return/enter key is pressed ap: review+

Description Marco Barisione 2008-04-08 02:55:03 PDT
It's possible to navigate among links and widgets using TAB and shift-TABS but then it's impossible to emulate a click on a button using the ENTER key.
Comment 1 Marco Barisione 2008-04-08 03:06:49 PDT
Created attachment 20402 [details]
Set the text of the event to '\r' when the return/enter key is pressed

Note that I used '\r' instead of '\n' because it's what WebCore use. Probably it's better to use '\n' modifying WebCore to allow this, but I think there could be a lot of places in WebCore where the code assumes that enter is '\r'. What do you think?
Comment 2 Alp Toker 2008-04-17 17:22:48 PDT
(In reply to comment #1)
> Created an attachment (id=20402) [edit]
> Set the text of the event to '\r' when the return/enter key is pressed
> 
> Note that I used '\r' instead of '\n' because it's what WebCore use. Probably
> it's better to use '\n' modifying WebCore to allow this, but I think there
> could be a lot of places in WebCore where the code assumes that enter is '\r'.
> What do you think?
> 

Yeah. While this fix looks like it'll work I think it'd be great to investigate if this can be fixed better in WebCore.

Marco: It's up to you. I can land this patch if you're willing to follow it up with a proper fix (if necessary), or I can leave it out till we get a better idea of how to proceed. It might be worth talking with ap (Alexey) about this one, he has a good eye for input issues.
Comment 3 Alexey Proskuryakov 2008-04-17 23:56:49 PDT
Comment on attachment 20402 [details]
Set the text of the event to '\r' when the return/enter key is pressed

It's surprising that gdk_keyval_to_unicode doesn't handle these keys - what is the story behind this? I couldn't find any hints in documentation. Are there any other keys that need to be special cased?

Yes, it is correct to use \r here - JavaScript code on the Web expects to see 0x13 in keypress.charCode, so this is not just internal to WebCore.

I have noticed that windowsKeyCodeForKeyEvent doesn't handle GDK_ISO_Enter and GDK_KP_Enter - this looks worth fixing, too.

r=me
Comment 4 Marco Barisione 2008-04-18 03:41:30 PDT
(In reply to comment #3)
> It's surprising that gdk_keyval_to_unicode doesn't handle these keys - what is
> the story behind this? I couldn't find any hints in documentation. Are there
> any other keys that need to be special cased?

I don't know (I will ping someone on IRC about this) but probably it would return \n not \r, so we would need to special case it even if gdk was changed.

Alp, can you commit the patch?

> I have noticed that windowsKeyCodeForKeyEvent doesn't handle GDK_ISO_Enter and
> GDK_KP_Enter - this looks worth fixing, too.

Opened another bug on this (bug #18576).
Comment 5 Alp Toker 2008-04-19 19:50:43 PDT
Landed in r32246.

Barisione, can you open another bug if there are other places this needs to be fixed or if it turns out we can fix this in a better place?

Cheers