[Webkit-unassigned] [Bug 16735] keyboard events created with DOM have keyCode and charCode of 0; thus they aren't handled correctly internally

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Dec 16 05:24:44 PST 2010


https://bugs.webkit.org/show_bug.cgi?id=16735





--- Comment #26 from apandia.ttg at gmail.com  2010-12-16 05:24:43 PST ---
Found an another way (think better then previous one) :)

1.In "EditorClientQt::handleKeyboardEvent" all the operation is based on PlatformKeyboardEvent. But for the case of events with "initKeyboardEvent" we normally don't have the required one.So used the keycode corresponding to the "KeyboardEvent" :-
    //Don't have a platformkeyboardevent(case of initKeyboardEvent.)
    //For such cases check for any assoaciated keycode
    if(!kevent) {
        switch(event->keyCode()){
            case VK_END:
                frame->editor()->command("MoveToEndOfLine").execute();
                return;
            case VK_HOME:
                frame->editor()->command("MoveToBeginningOfLine").execute();
                return;
            default:
                if(equalIgnoringCase(event->type(), "KeyDown")) {
                    String str = event->stringForKeyEvent();
                    if(!str.isEmpty())
                        frame->editor()->insertText(str, event);
                }
                return;
        }
    }
2.Implemented the "keyCodeForKeyIdentifier" (earlier returning 0)
static unsigned keyCodeForKeyIdentifier(const String& keyIdentifier)
{
    return windowsKeyCodeForKeyEvent(charCodeForKeyIdentifier(keyIdentifier));
}
3.Modified the keyIdentifierList as follows
    original:- keyIdentifierList.set("Exclamation", '!');
    Modified:- keyIdentifierList.set("U+0021", '!');
4.Added a new method in "KeyboardEvent" to return the corresponding string:-
String KeyboardEvent::stringForKeyEvent()
{
    String eventString;

    //Find the string in the keyidentifier list
    HashMap<String, unsigned>::iterator itt = keyIdentifierList()->find(m_keyIdentifier);
    if (itt != keyIdentifierList()->end())
        eventString.append(UChar(itt->second));

    //Now check if the keycode represents any printable character
    if(eventString.isEmpty() && PlatformKeyboardEvent::isVirtualKeyCodeRepresentingCharacter(keyCode()))
        eventString.append(UChar(keyCode()));

    return eventString;
}

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list