| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | |
| 3 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions | |
| 7 * are met: | |
| 8 * 1. Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | |
| 11 * notice, this list of conditions and the following disclaimer in the | |
| 12 * documentation and/or other materials provided with the distribution. | |
| 13 * | |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 25 */ | |
| 26 | |
| 27 #ifndef PlatformKeyboardEvent_h | |
| 28 #define PlatformKeyboardEvent_h | |
| 29 | |
| 30 #include "platform/PlatformEvent.h" | |
| 31 #include "wtf/text/WTFString.h" | |
| 32 | |
| 33 namespace WebCore { | |
| 34 | |
| 35 class PlatformKeyboardEvent : public PlatformEvent { | |
| 36 WTF_MAKE_FAST_ALLOCATED; | |
| 37 public: | |
| 38 PlatformKeyboardEvent() | |
| 39 : PlatformEvent(PlatformEvent::KeyDown) | |
| 40 , m_windowsVirtualKeyCode(0) | |
| 41 , m_nativeVirtualKeyCode(0) | |
| 42 , m_macCharCode(0) | |
| 43 , m_autoRepeat(false) | |
| 44 , m_isKeypad(false) | |
| 45 , m_isSystemKey(false) | |
| 46 { | |
| 47 } | |
| 48 | |
| 49 PlatformKeyboardEvent(Type type, const String& text, const String& unmod
ifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVir
tualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey
, Modifiers modifiers, double timestamp) | |
| 50 : PlatformEvent(type, modifiers, timestamp) | |
| 51 , m_text(text) | |
| 52 , m_unmodifiedText(unmodifiedText) | |
| 53 , m_keyIdentifier(keyIdentifier) | |
| 54 , m_windowsVirtualKeyCode(windowsVirtualKeyCode) | |
| 55 , m_nativeVirtualKeyCode(nativeVirtualKeyCode) | |
| 56 , m_macCharCode(macCharCode) | |
| 57 , m_autoRepeat(isAutoRepeat) | |
| 58 , m_isKeypad(isKeypad) | |
| 59 , m_isSystemKey(isSystemKey) | |
| 60 { | |
| 61 } | |
| 62 | |
| 63 void disambiguateKeyDownEvent(Type); | |
| 64 | |
| 65 // Text as as generated by processing a virtual key code with a keyboard
layout | |
| 66 // (in most cases, just a character code, but the layout can emit severa
l | |
| 67 // characters in a single keypress event on some platforms). | |
| 68 // This may bear no resemblance to the ultimately inserted text if an in
put method | |
| 69 // processes the input. | |
| 70 // Will be null for KeyUp and RawKeyDown events. | |
| 71 String text() const { return m_text; } | |
| 72 | |
| 73 // Text that would have been generated by the keyboard if no modifiers w
ere pressed | |
| 74 // (except for Shift); useful for shortcut (accelerator) key handling. | |
| 75 // Otherwise, same as text(). | |
| 76 String unmodifiedText() const { return m_unmodifiedText; } | |
| 77 | |
| 78 String keyIdentifier() const { return m_keyIdentifier; } | |
| 79 | |
| 80 // Most compatible Windows virtual key code associated with the event. | |
| 81 // Zero for Char events. | |
| 82 int windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; } | |
| 83 | |
| 84 int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; } | |
| 85 int macCharCode() const { return m_macCharCode; } | |
| 86 | |
| 87 bool isAutoRepeat() const { return m_autoRepeat; } | |
| 88 bool isKeypad() const { return m_isKeypad; } | |
| 89 bool isSystemKey() const { return m_isSystemKey; } | |
| 90 | |
| 91 static bool currentCapsLockState(); | |
| 92 static void getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool&
altKey, bool& metaKey); | |
| 93 protected: | |
| 94 String m_text; | |
| 95 String m_unmodifiedText; | |
| 96 String m_keyIdentifier; | |
| 97 int m_windowsVirtualKeyCode; | |
| 98 int m_nativeVirtualKeyCode; | |
| 99 int m_macCharCode; | |
| 100 bool m_autoRepeat; | |
| 101 bool m_isKeypad; | |
| 102 bool m_isSystemKey; | |
| 103 }; | |
| 104 | |
| 105 } // namespace WebCore | |
| 106 | |
| 107 #endif // PlatformKeyboardEvent_h | |
| OLD | NEW |