Beispiel #1
0
PlatformKeyboardEvent::PlatformKeyboardEvent(int keyCode, UChar32 unichar,
        int repeatCount, bool down, bool cap, bool alt, bool sym)
    : m_type(down ? KeyDown : KeyUp)
    , m_text(singleCharacterString(unichar))
    , m_unmodifiedText(singleCharacterString(unichar))
    , m_keyIdentifier(keyIdentifierForAndroidKeyCode(keyCode))
    , m_autoRepeat(repeatCount > 0)
    , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(keyCode))
    , m_nativeVirtualKeyCode(keyCode)
    , m_isKeypad(false)
    , m_shiftKey(cap ? ShiftKey : 0)
    , m_ctrlKey(sym ? CtrlKey : 0)
    , m_altKey(alt ? AltKey : 0)
    , m_metaKey(0)
    // added for android
    , m_repeatCount(repeatCount)
    , m_unichar(unichar)
{
    // Copied from the mac port
    if (m_windowsVirtualKeyCode == '\r') {
        m_text = "\r";
        m_unmodifiedText = "\r";
    }

    if (m_text == "\x7F")
        m_text = "\x8";
    if (m_unmodifiedText == "\x7F")
        m_unmodifiedText = "\x8";

    if (m_windowsVirtualKeyCode == 9) {
        m_text = "\x9";
        m_unmodifiedText = "\x9";
    }
}
PlatformKeyboardEvent::PlatformKeyboardEvent(int keyCode, UChar32 unichar,
                                             Type type, int repeatCount,
                                             ModifierKey mods)
    : m_type(type)
    , m_text(singleCharacterString(unichar))
    , m_unmodifiedText(singleCharacterString(unichar))
    , m_keyIdentifier(keyIdentifierForAndroidKeyCode(keyCode))
    , m_autoRepeat(repeatCount > 0)
    , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(keyCode))
    , m_nativeVirtualKeyCode(keyCode)
    , m_isKeypad(false)
    , m_shiftKey((mods & ShiftKey))
    , m_ctrlKey((mods & CtrlKey))
    , m_altKey((mods & AltKey))
    , m_metaKey((mods & MetaKey))
    // added for android
    , m_repeatCount(repeatCount)
    , m_unichar(unichar)
{
    // Copied from the mac port
    if (m_windowsVirtualKeyCode == '\r') {
        m_text = "\r";
        m_unmodifiedText = "\r";
    }

    if (m_text == "\x7F")
        m_text = "\x8";
    if (m_unmodifiedText == "\x7F")
        m_unmodifiedText = "\x8";

    if (m_windowsVirtualKeyCode == 9) {
        m_text = "\x9";
        m_unmodifiedText = "\x9";
    }
}
PlatformKeyboardEvent::PlatformKeyboardEvent(const Evas_Event_Key_Up* event)
    : PlatformEvent(PlatformEvent::KeyUp, evas_key_modifier_is_set(event->modifiers, "Shift"), evas_key_modifier_is_set(event->modifiers, "Control"), evas_key_modifier_is_set(event->modifiers, "Alt"), evas_key_modifier_is_set(event->modifiers, "Meta"), currentTime())
    , m_text(singleCharacterString(String::fromUTF8(event->string)))
    , m_unmodifiedText(singleCharacterString(String::fromUTF8(event->string)))
    , m_keyIdentifier(keyIdentifierForEvasKeyName(String(event->key)))
    , m_windowsVirtualKeyCode(windowsKeyCodeForEvasKeyName(String(event->key)))
    , m_nativeVirtualKeyCode(0)
    , m_macCharCode(0)
    , m_autoRepeat(false)
    , m_isKeypad(false)
    , m_isSystemKey(false)
{
}
Beispiel #4
0
PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData, Type type, bool systemKey)
    : PlatformEvent(type, GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, false, ::GetTickCount() * 0.001)
    , m_text((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
    , m_unmodifiedText((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
    , m_keyIdentifier((type == PlatformEvent::Char) ? String() : keyIdentifierForWindowsKeyCode(code))
    , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? code : 0)
    , m_nativeVirtualKeyCode(m_windowsVirtualKeyCode)
    , m_macCharCode(0)
    , m_autoRepeat(HIWORD(keyData) & KF_REPEAT)
    , m_isKeypad(isKeypadEvent(code, keyData, type))
    , m_isSystemKey(systemKey)
{
}
// Keep this in sync with the other platform event constructors
// TODO: m_gdkEventKey should be refcounted
PlatformKeyboardEvent::PlatformKeyboardEvent(GdkEventKey* event)
    : PlatformEvent((event->type == GDK_KEY_RELEASE) ? PlatformEvent::KeyUp : PlatformEvent::KeyDown, (event->state & GDK_SHIFT_MASK) || (event->keyval == GDK_3270_BackTab), event->state & GDK_CONTROL_MASK, event->state & GDK_MOD1_MASK, event->state & GDK_META_MASK, currentTime())
    , m_text(singleCharacterString(event->keyval))
    , m_unmodifiedText(singleCharacterString(event->keyval))
    , m_keyIdentifier(keyIdentifierForGdkKeyCode(event->keyval))
    , m_windowsVirtualKeyCode(windowsKeyCodeForGdkKeyCode(event->keyval))
    , m_nativeVirtualKeyCode(event->keyval)
    , m_macCharCode(0)
    , m_autoRepeat(false)
    , m_isKeypad(event->keyval >= GDK_KP_Space && event->keyval <= GDK_KP_9)
    , m_isSystemKey(false)
    , m_gdkEventKey(event)
{
}
PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData, Type type, bool systemKey)
    : m_type(type)
    , m_text((type == Char) ? singleCharacterString(code) : String())
    , m_unmodifiedText((type == Char) ? singleCharacterString(code) : String())
    , m_keyIdentifier((type == Char) ? String() : keyIdentifierForWindowsKeyCode(code))
    , m_autoRepeat(HIWORD(keyData) & KF_REPEAT)
    , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? code : 0)
    , m_isKeypad(isKeypadEvent(code, keyData, type))
    , m_shiftKey(GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT)
    , m_ctrlKey(GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT)
    , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT)
    , m_metaKey(false)
    , m_isSystemKey(systemKey)
{
}
Beispiel #7
0
PlatformKeyboardEvent::PlatformKeyboardEvent(HWND hWnd, WPARAM wParam, LPARAM lParam)
    : m_text(singleCharacterString(wParam))
    , m_unmodifiedText(singleCharacterString(wParam))
    , m_keyIdentifier(keyIdentifierForWindowsKeyCode(wParam))
    , m_isKeyUp((lParam & NEW_RELEASE_STATE_MASK))
    , m_autoRepeat(lParam & REPEAT_COUNT_MASK)
    , m_WindowsKeyCode(wParam)
    , m_isKeypad(false) // FIXME
    , m_shiftKey(GetAsyncKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT)
    , m_ctrlKey(GetAsyncKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT)
    , m_altKey(lParam & ALT_KEY_DOWN_MASK)
    , m_metaKey(lParam & ALT_KEY_DOWN_MASK) // FIXME: Is this right?
{
    if (!m_shiftKey)
        m_text = String(singleCharacterString(tolower(wParam)));
}
// Keep this in sync with the other platform event constructors
// TODO: m_gdkEventKey should be refcounted
PlatformKeyboardEvent::PlatformKeyboardEvent(GdkEventKey* event)
    : m_type((event->type == GDK_KEY_RELEASE) ? KeyUp : KeyDown)
    , m_text(singleCharacterString(event->keyval))
    , m_unmodifiedText(singleCharacterString(event->keyval))
    , m_keyIdentifier(keyIdentifierForGdkKeyCode(event->keyval))
    , m_autoRepeat(false)
    , m_windowsVirtualKeyCode(windowsKeyCodeForGdkKeyCode(event->keyval))
    , m_nativeVirtualKeyCode(event->keyval)
    , m_isKeypad(event->keyval >= GDK_KP_Space && event->keyval <= GDK_KP_9)
    , m_shiftKey((event->state & GDK_SHIFT_MASK) || (event->keyval == GDK_3270_BackTab))
    , m_ctrlKey(event->state & GDK_CONTROL_MASK)
    , m_altKey(event->state & GDK_MOD1_MASK)
    , m_metaKey(event->state & GDK_META_MASK)
    , m_gdkEventKey(event)
{
}
Beispiel #9
0
// Keep this in sync with the other platform event constructors
// TODO: m_gdkEventKey should be refcounted
PlatformKeyboardEvent::PlatformKeyboardEvent(GdkEventKey* event)
    : m_type((event->type == GDK_KEY_RELEASE) ? KeyUp : KeyDown)
    , m_text(singleCharacterString(event->keyval))
    , m_unmodifiedText(singleCharacterString(event->keyval))
    , m_keyIdentifier(keyIdentifierForGdkKeyCode(event->keyval))
    , m_autoRepeat(false)
    , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(event->keyval))
    , m_isKeypad(event->keyval >= GDK_KP_Space && event->keyval <= GDK_KP_9)
    , m_shiftKey((event->state & GDK_SHIFT_MASK) || (event->keyval == GDK_3270_BackTab))
    , m_ctrlKey(event->state & GDK_CONTROL_MASK)
    , m_altKey(event->state & GDK_MOD1_MASK)
#if GTK_CHECK_VERSION(2,10,0)
    , m_metaKey(event->state & GDK_META_MASK)
#else
    // GDK_MOD2_MASK doesn't always mean meta so we can't use it
    , m_metaKey(false)
#endif
    , m_gdkEventKey(event)
{
}
Beispiel #10
0
PlatformKeyboardEvent::PlatformKeyboardEvent( Type type
                                            , unsigned int winCharCode
                                            , unsigned int winKeyCode
                                            , bool isShiftKey
                                            , bool isCtrlKey
                                            , bool isAltKey
                                            , bool isMetaKey
                                            , bool isAutoRepeat
                                            )
    // we populate m_text/m_unmodifiedText on keyDown as the charCode is needed by swf in HTML on mac
    : m_type(type)
    , m_text(winCharCode ? singleCharacterString(winCharCode) : String())
    , m_unmodifiedText(winCharCode ? singleCharacterString(winCharCode) :  String())
    , m_keyIdentifier((type == Char) ? String() : keyIdentifierForWindowsKeyCode(winKeyCode))
    , m_autoRepeat(isAutoRepeat)
    , m_windowsVirtualKeyCode(winKeyCode ? winKeyCode : 0)
    , m_isKeypad(isKeypadEvent(winKeyCode, /*keyData,*/ type))
    , m_shiftKey(isShiftKey)
    , m_ctrlKey(isCtrlKey)
    , m_altKey(isAltKey)
    , m_metaKey(isMetaKey)
{
}
// Keep this in sync with the other platform event constructors
PlatformKeyboardEvent::PlatformKeyboardEvent(GdkEventKey* event, const CompositionResults& compositionResults)
    : PlatformEvent(eventTypeForGdkKeyEvent(event), modifiersForGdkKeyEvent(event), currentTime())
    , m_text(compositionResults.simpleString.length() ? compositionResults.simpleString : singleCharacterString(event->keyval))
    , m_unmodifiedText(m_text)
    , m_keyIdentifier(keyIdentifierForGdkKeyCode(event->keyval))
    , m_windowsVirtualKeyCode(windowsKeyCodeForGdkKeyCode(event->keyval))
    , m_nativeVirtualKeyCode(event->keyval)
    , m_macCharCode(0)
    , m_autoRepeat(false)
    , m_isKeypad(event->keyval >= GDK_KP_Space && event->keyval <= GDK_KP_9)
    , m_isSystemKey(false)
    , m_gdkEventKey(event)
    , m_compositionResults(compositionResults)
{
    // To match the behavior of IE, we return VK_PROCESSKEY for keys that triggered composition results.
    if (compositionResults.compositionUpdated())
        m_windowsVirtualKeyCode = VK_PROCESSKEY;
}