Chromium Code Reviews| 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 // This class describe a keyboard accelerator (or keyboard shortcut). | 5 // This class describe a keyboard accelerator (or keyboard shortcut). |
| 6 // Keyboard accelerators are registered with the FocusManager. | 6 // Keyboard accelerators are registered with the FocusManager. |
| 7 // It has a copy constructor and assignment operator so that it can be copied. | 7 // It has a copy constructor and assignment operator so that it can be copied. |
| 8 // It also defines the < operator so that it can be used as a key in a std::map. | 8 // It also defines the < operator so that it can be used as a key in a std::map. |
| 9 // | 9 // |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 | 82 |
| 83 void set_platform_accelerator(std::unique_ptr<PlatformAccelerator> p) { | 83 void set_platform_accelerator(std::unique_ptr<PlatformAccelerator> p) { |
| 84 platform_accelerator_ = std::move(p); | 84 platform_accelerator_ = std::move(p); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // This class keeps ownership of the returned object. | 87 // This class keeps ownership of the returned object. |
| 88 const PlatformAccelerator* platform_accelerator() const { | 88 const PlatformAccelerator* platform_accelerator() const { |
| 89 return platform_accelerator_.get(); | 89 return platform_accelerator_.get(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void set_interrupted_by_mouse_event(bool interrupted_by_mouse_event) { | |
| 93 interrupted_by_mouse_event_ = interrupted_by_mouse_event; | |
| 94 } | |
| 95 | |
| 96 bool is_interrupted_by_mouse_event() const { | |
|
oshima
2017/07/07 22:28:41
nit: interrupted_by_mouse_event()
(or you can ren
weidongg
2017/07/07 22:55:31
Done.
| |
| 97 return interrupted_by_mouse_event_; | |
| 98 } | |
| 99 | |
| 92 private: | 100 private: |
| 93 // The keycode (VK_...). | 101 // The keycode (VK_...). |
| 94 KeyboardCode key_code_; | 102 KeyboardCode key_code_; |
| 95 | 103 |
| 96 KeyState key_state_; | 104 KeyState key_state_; |
| 97 | 105 |
| 98 // The state of the Shift/Ctrl/Alt keys. This corresponds to Event::flags(). | 106 // The state of the Shift/Ctrl/Alt keys. This corresponds to Event::flags(). |
| 99 int modifiers_; | 107 int modifiers_; |
| 100 | 108 |
| 101 // Stores platform specific data. May be NULL. | 109 // Stores platform specific data. May be NULL. |
| 102 // TODO: this is only used in Mac code and should be removed from here. | 110 // TODO: this is only used in Mac code and should be removed from here. |
| 103 // http://crbug.com/702823. | 111 // http://crbug.com/702823. |
| 104 std::unique_ptr<PlatformAccelerator> platform_accelerator_; | 112 std::unique_ptr<PlatformAccelerator> platform_accelerator_; |
| 113 | |
| 114 // Whether the accelerator is interrupted by a mouse press/release. This is | |
| 115 // optionally used by AcceleratorController. Even this is set to true, the | |
| 116 // accelerator may still be handled successfully. (Currently only | |
| 117 // TOGGLE_APP_LIST is disabled when mouse press/release occurs between | |
| 118 // search key down and up. See crbug.com/665897) | |
| 119 bool interrupted_by_mouse_event_; | |
| 105 }; | 120 }; |
| 106 | 121 |
| 107 // An interface that classes that want to register for keyboard accelerators | 122 // An interface that classes that want to register for keyboard accelerators |
| 108 // should implement. | 123 // should implement. |
| 109 class UI_BASE_EXPORT AcceleratorTarget { | 124 class UI_BASE_EXPORT AcceleratorTarget { |
| 110 public: | 125 public: |
| 111 // Should return true if the accelerator was processed. | 126 // Should return true if the accelerator was processed. |
| 112 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; | 127 virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; |
| 113 | 128 |
| 114 // Should return true if the target can handle the accelerator events. The | 129 // Should return true if the target can handle the accelerator events. The |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 130 virtual bool GetAcceleratorForCommandId(int command_id, | 145 virtual bool GetAcceleratorForCommandId(int command_id, |
| 131 Accelerator* accelerator) const = 0; | 146 Accelerator* accelerator) const = 0; |
| 132 | 147 |
| 133 protected: | 148 protected: |
| 134 virtual ~AcceleratorProvider() {} | 149 virtual ~AcceleratorProvider() {} |
| 135 }; | 150 }; |
| 136 | 151 |
| 137 } // namespace ui | 152 } // namespace ui |
| 138 | 153 |
| 139 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_H_ | 154 #endif // UI_BASE_ACCELERATORS_ACCELERATOR_H_ |
| OLD | NEW |