OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_EVENTS_SCOPED_TARGET_HANDLER_H_ | |
6 #define UI_EVENTS_SCOPED_TARGET_HANDLER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "ui/events/event_handler.h" | |
10 #include "ui/events/events_export.h" | |
11 | |
12 namespace ui { | |
13 | |
14 class EventTarget; | |
15 | |
16 // An EventHandler that replaces an EventTarget's target handler with itself | |
17 // to handle events on target or pass them to be handled in descendants. | |
18 class EVENTS_EXPORT ScopedTargetHandler : public EventHandler { | |
19 public: | |
20 ScopedTargetHandler(EventTarget* target); | |
bruthig
2015/11/20 16:25:33
I think the ScopedTargetHandler should still accep
varkha
2015/11/20 17:48:26
Acknowledged.
varkha
2015/11/21 01:07:37
Done.
| |
21 ~ScopedTargetHandler() override; | |
22 | |
23 // ui::EventHandler: | |
24 void OnEvent(ui::Event* event) override; | |
25 void OnKeyEvent(ui::KeyEvent* event) override; | |
26 void OnMouseEvent(ui::MouseEvent* event) override; | |
27 void OnScrollEvent(ui::ScrollEvent* event) override; | |
28 void OnTouchEvent(ui::TouchEvent* event) override; | |
29 void OnGestureEvent(ui::GestureEvent* event) override; | |
30 void OnCancelMode(ui::CancelModeEvent* event) override; | |
31 | |
32 private: | |
33 // An EventTarget that has its target handler replaced with |this| for a life | |
34 // time of |this|. | |
35 EventTarget* target_; | |
36 | |
37 // An EventHandler that gets restored on |target_| when |this| is destroyed. | |
38 EventHandler* original_handler_; | |
39 | |
40 DISALLOW_COPY_AND_ASSIGN(ScopedTargetHandler); | |
41 }; | |
42 | |
43 } // namespace ui | |
44 | |
45 #endif // UI_EVENTS_SCOPED_TARGET_HANDLER_H_ | |
OLD | NEW |