Chromium Code Reviews| 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_ | |
|
sadrul
2015/11/27 05:59:36
update after the move
varkha
2015/11/27 15:17:03
Done.
| |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "ui/events/event_handler.h" | |
| 10 #include "ui/views/views_export.h" | |
| 11 | |
| 12 namespace views { | |
| 13 | |
| 14 class View; | |
| 15 | |
| 16 // An EventHandler that replaces an View's target handler with itself to pass | |
| 17 // events first to the original handlers and second to an additional new | |
| 18 // EventHandler. The new handler gets called after the original handlers even | |
| 19 // if they call SetHandled() or StopPropagation() on the event. | |
| 20 class VIEWS_EXPORT ScopedTargetHandler : public ui::EventHandler { | |
| 21 public: | |
| 22 ScopedTargetHandler(View* view, ui::EventHandler* new_handler); | |
| 23 ~ScopedTargetHandler() override; | |
| 24 | |
| 25 // ui::EventHandler: | |
| 26 void OnEvent(ui::Event* event) override; | |
| 27 void OnKeyEvent(ui::KeyEvent* event) override; | |
| 28 void OnMouseEvent(ui::MouseEvent* event) override; | |
| 29 void OnScrollEvent(ui::ScrollEvent* event) override; | |
| 30 void OnTouchEvent(ui::TouchEvent* event) override; | |
| 31 void OnGestureEvent(ui::GestureEvent* event) override; | |
| 32 void OnCancelMode(ui::CancelModeEvent* event) override; | |
| 33 | |
| 34 private: | |
| 35 // If non-null the destructor sets this to true. This is set while handling | |
| 36 // an event and used to detect if |this| has been deleted. | |
| 37 bool* destroyed_flag_; | |
| 38 | |
| 39 // An View that has its target handler replaced with |this| for a life time of | |
| 40 // |this|. | |
| 41 View* view_; | |
| 42 | |
| 43 // An EventHandler that gets restored on |view_| when |this| is destroyed. | |
| 44 ui::EventHandler* original_handler_; | |
| 45 | |
| 46 // A new handler that gets events in addition to the |original_handler_| or | |
| 47 // |view_|. | |
| 48 ui::EventHandler* new_handler_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(ScopedTargetHandler); | |
| 51 }; | |
| 52 | |
| 53 } // namespace views | |
| 54 | |
| 55 #endif // UI_EVENTS_SCOPED_TARGET_HANDLER_H_ | |
| OLD | NEW |