OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_EVENTS_EVENT_H_ | 5 #ifndef UI_EVENTS_EVENT_H_ |
6 #define UI_EVENTS_EVENT_H_ | 6 #define UI_EVENTS_EVENT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/event_types.h" | 10 #include "base/event_types.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } | 88 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } |
89 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } | 89 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } |
90 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; } | 90 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; } |
91 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } | 91 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } |
92 bool IsAltGrDown() const { return (flags_ & EF_ALTGR_DOWN) != 0; } | 92 bool IsAltGrDown() const { return (flags_ & EF_ALTGR_DOWN) != 0; } |
93 bool IsCommandDown() const { return (flags_ & EF_COMMAND_DOWN) != 0; } | 93 bool IsCommandDown() const { return (flags_ & EF_COMMAND_DOWN) != 0; } |
94 bool IsRepeat() const { return (flags_ & EF_IS_REPEAT) != 0; } | 94 bool IsRepeat() const { return (flags_ & EF_IS_REPEAT) != 0; } |
95 | 95 |
96 bool IsKeyEvent() const { | 96 bool IsKeyEvent() const { |
97 return type_ == ET_KEY_PRESSED || | 97 return type_ == ET_KEY_PRESSED || |
98 type_ == ET_KEY_RELEASED || | 98 type_ == ET_KEY_RELEASED; |
99 type_ == ET_TRANSLATED_KEY_PRESS || | |
100 type_ == ET_TRANSLATED_KEY_RELEASE; | |
101 } | 99 } |
102 | 100 |
103 bool IsMouseEvent() const { | 101 bool IsMouseEvent() const { |
104 return type_ == ET_MOUSE_PRESSED || | 102 return type_ == ET_MOUSE_PRESSED || |
105 type_ == ET_MOUSE_DRAGGED || | 103 type_ == ET_MOUSE_DRAGGED || |
106 type_ == ET_MOUSE_RELEASED || | 104 type_ == ET_MOUSE_RELEASED || |
107 type_ == ET_MOUSE_MOVED || | 105 type_ == ET_MOUSE_MOVED || |
108 type_ == ET_MOUSE_ENTERED || | 106 type_ == ET_MOUSE_ENTERED || |
109 type_ == ET_MOUSE_EXITED || | 107 type_ == ET_MOUSE_EXITED || |
110 type_ == ET_MOUSEWHEEL || | 108 type_ == ET_MOUSEWHEEL || |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 | 593 |
596 virtual ExtendedKeyEventData* Clone() const = 0; | 594 virtual ExtendedKeyEventData* Clone() const = 0; |
597 }; | 595 }; |
598 | 596 |
599 // A KeyEvent is really two distinct classes, melded together due to the | 597 // A KeyEvent is really two distinct classes, melded together due to the |
600 // DOM legacy of Windows key events: a keystroke event (is_char_ == false), | 598 // DOM legacy of Windows key events: a keystroke event (is_char_ == false), |
601 // or a character event (is_char_ == true). | 599 // or a character event (is_char_ == true). |
602 // | 600 // |
603 // For a keystroke event, | 601 // For a keystroke event, |
604 // -- is_char_ is false. | 602 // -- is_char_ is false. |
605 // -- Event::type() can be any one of ET_KEY_PRESSED, ET_KEY_RELEASED, | 603 // -- Event::type() can be any one of ET_KEY_PRESSED, ET_KEY_RELEASED. |
606 // ET_TRANSLATED_KEY_PRESS, or ET_TRANSLATED_KEY_RELEASE. | |
607 // -- code_ and Event::flags() represent the physical key event. | 604 // -- code_ and Event::flags() represent the physical key event. |
608 // - code_ is a platform-independent representation of the physical key, | 605 // - code_ is a platform-independent representation of the physical key, |
609 // based on DOM KeyboardEvent |code| values. It does not vary depending | 606 // based on DOM KeyboardEvent |code| values. It does not vary depending |
610 // on key layout. | 607 // on key layout. |
611 // - Event::flags() provides the active modifiers for the physical key | 608 // - Event::flags() provides the active modifiers for the physical key |
612 // press. Its value reflects the state after the event; that is, for | 609 // press. Its value reflects the state after the event; that is, for |
613 // a modifier key, a press includes the corresponding flag and a release | 610 // a modifier key, a press includes the corresponding flag and a release |
614 // does not. | 611 // does not. |
615 // -- key_ and character_ provide the meaning of the key event, in the context | 612 // -- key_ and character_ provide the meaning of the key event, in the context |
616 // of the active layout and modifiers. Together they correspond to DOM | 613 // of the active layout and modifiers. Together they correspond to DOM |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
737 DomCode code() const { return code_; }; | 734 DomCode code() const { return code_; }; |
738 std::string GetCodeString() const; | 735 std::string GetCodeString() const; |
739 | 736 |
740 // Returns the DOM .key (layout meaning) for a keystroke event. | 737 // Returns the DOM .key (layout meaning) for a keystroke event. |
741 DomKey GetDomKey() const; | 738 DomKey GetDomKey() const; |
742 | 739 |
743 // Normalizes flags_ so that it describes the state after the event. | 740 // Normalizes flags_ so that it describes the state after the event. |
744 // (Native X11 event flags describe the state before the event.) | 741 // (Native X11 event flags describe the state before the event.) |
745 void NormalizeFlags(); | 742 void NormalizeFlags(); |
746 | 743 |
747 // Returns true if the key event has already been processed by an input method | |
748 // and there is no need to pass the key event to the input method again. | |
749 bool IsTranslated() const; | |
James Cook
2015/06/01 22:21:00
Seeing things like this being removed makes me hap
Shu Chen
2015/06/02 04:11:16
Me too! :-)
| |
750 // Marks this key event as translated or not translated. | |
751 void SetTranslated(bool translated); | |
752 | |
753 protected: | 744 protected: |
754 friend class KeyEventTestApi; | 745 friend class KeyEventTestApi; |
755 | 746 |
756 // This allows a subclass TranslatedKeyEvent to be a non character event. | 747 // This allows a subclass TranslatedKeyEvent to be a non character event. |
757 void set_is_char(bool is_char) { is_char_ = is_char; } | 748 void set_is_char(bool is_char) { is_char_ = is_char; } |
758 | 749 |
759 private: | 750 private: |
760 // Determine key_ and character_ on a keystroke event from code_ and flags(). | 751 // Determine key_ and character_ on a keystroke event from code_ and flags(). |
761 void ApplyLayout() const; | 752 void ApplyLayout() const; |
762 | 753 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
879 | 870 |
880 const GestureEventDetails& details() const { return details_; } | 871 const GestureEventDetails& details() const { return details_; } |
881 | 872 |
882 private: | 873 private: |
883 GestureEventDetails details_; | 874 GestureEventDetails details_; |
884 }; | 875 }; |
885 | 876 |
886 } // namespace ui | 877 } // namespace ui |
887 | 878 |
888 #endif // UI_EVENTS_EVENT_H_ | 879 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |