2
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
3
* Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4
* Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5
* Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Library General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Library General Public License for more details.
17
* You should have received a copy of the GNU Library General Public License
18
* along with this library; see the file COPYING.LIB. If not, write to
19
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
24
#ifndef KeyboardEvent_h
25
#define KeyboardEvent_h
27
#include "UIEventWithKeyState.h"
28
#include <wtf/Vector.h>
32
class PlatformKeyboardEvent;
35
struct KeypressCommand {
36
Vector<String> commandNames;
39
bool isEmpty() const { return text.isEmpty() && commandNames.isEmpty(); }
43
// Introduced in DOM Level 3
44
class KeyboardEvent : public UIEventWithKeyState {
46
enum KeyLocationCode {
47
DOM_KEY_LOCATION_STANDARD = 0x00,
48
DOM_KEY_LOCATION_LEFT = 0x01,
49
DOM_KEY_LOCATION_RIGHT = 0x02,
50
DOM_KEY_LOCATION_NUMPAD = 0x03
54
KeyboardEvent(const PlatformKeyboardEvent&, AbstractView*);
55
KeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView*,
56
const String& keyIdentifier, unsigned keyLocation,
57
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey);
58
virtual ~KeyboardEvent();
60
void initKeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView*,
61
const String& keyIdentifier, unsigned keyLocation,
62
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey = false);
64
String keyIdentifier() const { return m_keyIdentifier; }
65
unsigned keyLocation() const { return m_keyLocation; }
67
bool getModifierState(const String& keyIdentifier) const;
69
bool altGraphKey() const { return m_altGraphKey; }
71
const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent; }
73
int keyCode() const; // key code for keydown and keyup, character for other events
76
virtual bool isKeyboardEvent() const;
77
virtual int which() const;
80
// We only have this need to store keypress command info on the Mac.
81
KeypressCommand keypressCommand() { return m_keypressCommand; }
82
void setKeypressCommand(const KeypressCommand& command) { m_keypressCommand = command; }
86
PlatformKeyboardEvent* m_keyEvent;
87
String m_keyIdentifier;
88
unsigned m_keyLocation;
89
bool m_altGraphKey : 1;
92
KeypressCommand m_keypressCommand;
96
KeyboardEvent* findKeyboardEvent(Event*);
98
} // namespace WebCore
100
#endif // KeyboardEvent_h