summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-04 16:51:02 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-04 16:51:02 +0000
commit1df2093adb550a8468b92929d8ec79160ea4045a (patch)
tree47c51b8c45555aa7bd5c84a804b6b426e9d4dac3 /ui
parent3f7e206e43ab10e0455d31b5339878e79c063ba7 (diff)
downloadchromium_src-1df2093adb550a8468b92929d8ec79160ea4045a.zip
chromium_src-1df2093adb550a8468b92929d8ec79160ea4045a.tar.gz
chromium_src-1df2093adb550a8468b92929d8ec79160ea4045a.tar.bz2
aura: Events handled in WindowDelegate will reach the post-target event handlers.
An event handled by the WindowDelegate should still reach the post-target event handlers. If a delegate wants to stop the event from reaching the post-target handlers, then it should override the EventHanlder implementation and return ER_CONSUMED. BUG=none Review URL: https://chromiumcodereview.appspot.com/10920069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154763 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/event_filter_unittest.cc109
-rw-r--r--ui/aura/shared/compound_event_filter.cc192
-rw-r--r--ui/aura/shared/compound_event_filter.h34
-rw-r--r--ui/aura/test/test_event_filter.cc32
-rw-r--r--ui/aura/test/test_event_filter.h40
-rw-r--r--ui/aura/window_delegate.cc4
6 files changed, 243 insertions, 168 deletions
diff --git a/ui/aura/event_filter_unittest.cc b/ui/aura/event_filter_unittest.cc
index d7d7103..d23d1e5 100644
--- a/ui/aura/event_filter_unittest.cc
+++ b/ui/aura/event_filter_unittest.cc
@@ -31,8 +31,8 @@ class TestEventFilterWindowDelegate : public test::TestWindowDelegate {
: key_event_count_(0),
mouse_event_count_(0),
touch_event_count_(0),
- consumes_key_events_(true),
- consumes_mouse_events_(true),
+ key_event_handling_result_(ui::ER_UNHANDLED),
+ mouse_event_handling_result_(ui::ER_UNHANDLED),
consumes_touch_events_(true) {}
virtual ~TestEventFilterWindowDelegate() {}
@@ -46,11 +46,11 @@ class TestEventFilterWindowDelegate : public test::TestWindowDelegate {
int mouse_event_count() const { return mouse_event_count_; }
int touch_event_count() const { return touch_event_count_; }
- void set_consumes_key_events(bool consumes_key_events) {
- consumes_key_events_ = consumes_key_events;
+ void set_key_event_handling_result(ui::EventResult result) {
+ key_event_handling_result_ = result;
}
- void set_consumes_mouse_events(bool consumes_mouse_events) {
- consumes_mouse_events_ = consumes_mouse_events;
+ void set_mouse_event_handling_result(ui::EventResult result) {
+ mouse_event_handling_result_ = result;
}
void set_consumes_touch_events(bool consumes_touch_events) {
consumes_touch_events_ = consumes_touch_events;
@@ -58,12 +58,10 @@ class TestEventFilterWindowDelegate : public test::TestWindowDelegate {
// Overridden from TestWindowDelegate:
virtual bool OnKeyEvent(ui::KeyEvent* event) OVERRIDE {
- ++key_event_count_;
- return consumes_key_events_;
+ return key_event_handling_result_ != ui::ER_UNHANDLED;
}
virtual bool OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
- ++mouse_event_count_;
- return consumes_mouse_events_;
+ return mouse_event_handling_result_ != ui::ER_UNHANDLED;
}
virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
++touch_event_count_;
@@ -76,12 +74,29 @@ class TestEventFilterWindowDelegate : public test::TestWindowDelegate {
return ui::ER_UNHANDLED;
}
+ // Overridden from EventHandler:
+ virtual ui::EventResult OnKeyEvent(ui::EventTarget* target,
+ ui::KeyEvent* event) OVERRIDE {
+ ++key_event_count_;
+ if (key_event_handling_result_ & ui::ER_CONSUMED)
+ return key_event_handling_result_;
+ return WindowDelegate::OnKeyEvent(target, event);
+ }
+
+ virtual ui::EventResult OnMouseEvent(ui::EventTarget* target,
+ ui::MouseEvent* event) OVERRIDE {
+ ++mouse_event_count_;
+ if (mouse_event_handling_result_ & ui::ER_CONSUMED)
+ return mouse_event_handling_result_;
+ return WindowDelegate::OnMouseEvent(target, event);
+ }
+
private:
int key_event_count_;
int mouse_event_count_;
int touch_event_count_;
- bool consumes_key_events_;
- bool consumes_mouse_events_;
+ ui::EventResult key_event_handling_result_;
+ ui::EventResult mouse_event_handling_result_;
bool consumes_touch_events_;
DISALLOW_COPY_AND_ASSIGN(TestEventFilterWindowDelegate);
@@ -148,8 +163,8 @@ TEST_F(EventFilterTest, PreHandle) {
w111_filter->ResetCounts();
// Now make w1's EF consume the event.
- w1_filter->set_consumes_key_events(true);
- w1_filter->set_consumes_mouse_events(true);
+ w1_filter->set_key_event_handling_result(ui::ER_CONSUMED);
+ w1_filter->set_mouse_event_handling_result(ui::ER_CONSUMED);
generator.ReleaseLeftButton();
root_window()->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event);
@@ -186,12 +201,13 @@ TEST_F(EventFilterTest, PostHandle) {
w1->GetFocusManager()->SetFocusedWindow(w11.get(), NULL);
// TODO(sadrul): TouchEvent/GestureEvent!
- // To start with, no one is going to consume any events. The pre-
+
+ // To start with, no one is going to consume any events. The post-
// event filters and w11's delegate will be notified.
test::EventGenerator generator(root_window(), w11.get());
- d11->set_consumes_key_events(false);
- d11->set_consumes_mouse_events(false);
+ d11->set_key_event_handling_result(ui::ER_UNHANDLED);
+ d11->set_mouse_event_handling_result(ui::ER_UNHANDLED);
d11->set_consumes_touch_events(false);
generator.PressKey(ui::VKEY_A, 0);
@@ -208,23 +224,58 @@ TEST_F(EventFilterTest, PostHandle) {
d11->ResetCounts();
generator.set_flags(0);
- // Let |w1_filter| consume an event. So the root-window's bubble-filter
- // should no longer receive the event.
- w1_filter->set_consumes_mouse_events(true);
+ // Let |w1_filter| handle (but not consume) an event. The root-window's
+ // post-target filter should still receive the event.
+ w1_filter->set_mouse_event_handling_result(ui::ER_HANDLED);
+ generator.PressLeftButton();
+ EXPECT_EQ(1, d11->mouse_event_count());
+ EXPECT_EQ(1, w1_filter->mouse_event_count());
+ EXPECT_EQ(1, root_window_filter->mouse_event_count());
+
+ root_window_filter->ResetCounts();
+ w1_filter->ResetCounts();
+ d11->ResetCounts();
+ generator.set_flags(0);
+
+ // Let |w1_filter| consume an event. So the root-window's post-target
+ // filter should no longer receive the event.
+ w1_filter->set_mouse_event_handling_result(ui::ER_CONSUMED);
generator.PressLeftButton();
EXPECT_EQ(1, d11->mouse_event_count());
EXPECT_EQ(1, w1_filter->mouse_event_count());
EXPECT_EQ(0, root_window_filter->mouse_event_count());
+ // Now we'll have the delegate handle the events.
+ root_window_filter->ResetCounts();
+ w1_filter->ResetCounts();
+ d11->ResetCounts();
+ generator.set_flags(0);
+
+ w1_filter->set_mouse_event_handling_result(ui::ER_UNHANDLED);
+ d11->set_key_event_handling_result(ui::ER_HANDLED);
+ d11->set_mouse_event_handling_result(ui::ER_HANDLED);
+ d11->set_consumes_touch_events(true);
+
+ generator.PressKey(ui::VKEY_A, 0);
+ generator.PressLeftButton();
+
+ EXPECT_EQ(1, d11->key_event_count());
+ EXPECT_EQ(1, d11->mouse_event_count());
+ // The delegate processed the event. But it should still bubble up to the
+ // post-target filters.
+ EXPECT_EQ(1, w1_filter->key_event_count());
+ EXPECT_EQ(1, root_window_filter->key_event_count());
+ EXPECT_EQ(1, w1_filter->mouse_event_count());
+ EXPECT_EQ(1, root_window_filter->mouse_event_count());
+
// Now we'll have the delegate consume the events.
root_window_filter->ResetCounts();
w1_filter->ResetCounts();
d11->ResetCounts();
generator.set_flags(0);
- w1_filter->set_consumes_mouse_events(false);
- d11->set_consumes_key_events(true);
- d11->set_consumes_mouse_events(true);
+ d11->set_key_event_handling_result(ui::ER_CONSUMED);
+ d11->set_mouse_event_handling_result(ui::ER_CONSUMED);
d11->set_consumes_touch_events(true);
generator.PressKey(ui::VKEY_A, 0);
@@ -232,8 +283,8 @@ TEST_F(EventFilterTest, PostHandle) {
EXPECT_EQ(1, d11->key_event_count());
EXPECT_EQ(1, d11->mouse_event_count());
- // The delegate processed the event. So it shouldn't bubble up to the bubble
- // filter.
+ // The delegate consumed the event. So it should no longer reach the
+ // post-target filters.
EXPECT_EQ(0, w1_filter->key_event_count());
EXPECT_EQ(0, root_window_filter->key_event_count());
EXPECT_EQ(0, w1_filter->mouse_event_count());
@@ -246,12 +297,12 @@ TEST_F(EventFilterTest, PostHandle) {
d11->ResetCounts();
generator.set_flags(0);
- d11->set_consumes_key_events(false);
- d11->set_consumes_mouse_events(false);
+ d11->set_key_event_handling_result(ui::ER_UNHANDLED);
+ d11->set_mouse_event_handling_result(ui::ER_UNHANDLED);
d11->set_consumes_touch_events(false);
- w1_filter->set_consumes_key_events(true);
- w1_filter->set_consumes_mouse_events(true);
+ w1_filter->set_key_event_handling_result(ui::ER_CONSUMED);
+ w1_filter->set_mouse_event_handling_result(ui::ER_CONSUMED);
w1_filter->set_consumes_touch_events(true);
generator.PressKey(ui::VKEY_A, 0);
diff --git a/ui/aura/shared/compound_event_filter.cc b/ui/aura/shared/compound_event_filter.cc
index ca2343f..9657345 100644
--- a/ui/aura/shared/compound_event_filter.cc
+++ b/ui/aura/shared/compound_event_filter.cc
@@ -83,82 +83,6 @@ size_t CompoundEventFilter::GetFilterCount() const {
}
////////////////////////////////////////////////////////////////////////////////
-// CompoundEventFilter, EventFilter implementation:
-
-bool CompoundEventFilter::PreHandleKeyEvent(Window* target,
- ui::KeyEvent* event) {
- return FilterKeyEvent(target, event);
-}
-
-bool CompoundEventFilter::PreHandleMouseEvent(Window* target,
- ui::MouseEvent* event) {
- WindowTracker window_tracker;
- window_tracker.Add(target);
-
- // We must always update the cursor, otherwise the cursor can get stuck if an
- // event filter registered with us consumes the event.
- // It should also update the cursor for clicking and wheels for ChromeOS boot.
- // When ChromeOS is booted, it hides the mouse cursor but immediate mouse
- // operation will show the cursor.
- if (event->type() == ui::ET_MOUSE_MOVED ||
- event->type() == ui::ET_MOUSE_PRESSED ||
- event->type() == ui::ET_MOUSEWHEEL) {
- SetCursorVisibilityOnEvent(target, event, true);
- UpdateCursor(target, event);
- }
-
- if (FilterMouseEvent(target, event) ||
- !window_tracker.Contains(target) ||
- !target->GetRootWindow()) {
- return true;
- }
-
- if (event->type() == ui::ET_MOUSE_PRESSED &&
- GetActiveWindow(target) != target) {
- target->GetFocusManager()->SetFocusedWindow(
- FindFocusableWindowFor(target), event);
- }
-
- return false;
-}
-
-ui::TouchStatus CompoundEventFilter::PreHandleTouchEvent(
- Window* target,
- ui::TouchEvent* event) {
- ui::TouchStatus status = FilterTouchEvent(target, event);
- if (status == ui::TOUCH_STATUS_UNKNOWN &&
- event->type() == ui::ET_TOUCH_PRESSED) {
- SetCursorVisibilityOnEvent(target, event, false);
- }
- return status;
-}
-
-ui::EventResult CompoundEventFilter::PreHandleGestureEvent(
- Window* target,
- ui::GestureEvent* event) {
- ui::EventResult status = ui::ER_UNHANDLED;
- if (filters_.might_have_observers()) {
- ObserverListBase<EventFilter>::Iterator it(filters_);
- EventFilter* filter;
- while (status == ui::ER_UNHANDLED &&
- (filter = it.GetNext()) != NULL) {
- status = filter->PreHandleGestureEvent(target, event);
- }
- }
-
- if (event->type() == ui::ET_GESTURE_BEGIN &&
- event->details().touch_points() == 1 &&
- status != ui::ER_CONSUMED &&
- target->GetRootWindow() &&
- GetActiveWindow(target) != target) {
- target->GetFocusManager()->SetFocusedWindow(
- FindFocusableWindowFor(target), event);
- }
-
- return status;
-}
-
-////////////////////////////////////////////////////////////////////////////////
// CompoundEventFilter, private:
void CompoundEventFilter::UpdateCursor(Window* target, ui::MouseEvent* event) {
@@ -176,27 +100,28 @@ void CompoundEventFilter::UpdateCursor(Window* target, ui::MouseEvent* event) {
}
}
-bool CompoundEventFilter::FilterKeyEvent(Window* target, ui::KeyEvent* event) {
- bool handled = false;
+ui::EventResult CompoundEventFilter::FilterKeyEvent(ui::EventTarget* target,
+ ui::KeyEvent* event) {
+ int result = ui::ER_UNHANDLED;
if (filters_.might_have_observers()) {
ObserverListBase<EventFilter>::Iterator it(filters_);
EventFilter* filter;
- while (!handled && (filter = it.GetNext()) != NULL)
- handled = filter->PreHandleKeyEvent(target, event);
+ while (!(result & ui::ER_CONSUMED) && (filter = it.GetNext()) != NULL)
+ result |= filter->OnKeyEvent(target, event);
}
- return handled;
+ return static_cast<ui::EventResult>(result);
}
-bool CompoundEventFilter::FilterMouseEvent(Window* target,
- ui::MouseEvent* event) {
- bool handled = false;
+ui::EventResult CompoundEventFilter::FilterMouseEvent(ui::EventTarget* target,
+ ui::MouseEvent* event) {
+ int result = ui::ER_UNHANDLED;
if (filters_.might_have_observers()) {
ObserverListBase<EventFilter>::Iterator it(filters_);
EventFilter* filter;
- while (!handled && (filter = it.GetNext()) != NULL)
- handled = filter->PreHandleMouseEvent(target, event);
+ while (!(result & ui::ER_CONSUMED) && (filter = it.GetNext()) != NULL)
+ result |= filter->OnMouseEvent(target, event);
}
- return handled;
+ return static_cast<ui::EventResult>(result);
}
ui::TouchStatus CompoundEventFilter::FilterTouchEvent(
@@ -208,7 +133,7 @@ ui::TouchStatus CompoundEventFilter::FilterTouchEvent(
EventFilter* filter;
while (status == ui::TOUCH_STATUS_UNKNOWN &&
(filter = it.GetNext()) != NULL) {
- status = filter->PreHandleTouchEvent(target, event);
+ status = filter->OnTouchEvent(target, event);
}
}
return status;
@@ -225,5 +150,96 @@ void CompoundEventFilter::SetCursorVisibilityOnEvent(aura::Window* target,
}
}
+////////////////////////////////////////////////////////////////////////////////
+// CompoundEventFilter, EventFilter implementation:
+
+ui::TouchStatus CompoundEventFilter::PreHandleTouchEvent(
+ Window* target,
+ ui::TouchEvent* event) {
+ // TODO(sad): Move the implementation into OnTouchEvent once touch-events are
+ // hooked up to go through EventDispatcher.
+ ui::TouchStatus status = FilterTouchEvent(target, event);
+ if (status == ui::TOUCH_STATUS_UNKNOWN &&
+ event->type() == ui::ET_TOUCH_PRESSED) {
+ SetCursorVisibilityOnEvent(target, event, false);
+ }
+ return status;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// CompoundEventFilter, ui::EventHandler implementation:
+
+ui::EventResult CompoundEventFilter::OnKeyEvent(ui::EventTarget* target,
+ ui::KeyEvent* event) {
+ return FilterKeyEvent(target, event);
+}
+
+ui::EventResult CompoundEventFilter::OnMouseEvent(ui::EventTarget* target,
+ ui::MouseEvent* event) {
+ Window* window = static_cast<Window*>(target);
+ WindowTracker window_tracker;
+ window_tracker.Add(window);
+
+ // We must always update the cursor, otherwise the cursor can get stuck if an
+ // event filter registered with us consumes the event.
+ // It should also update the cursor for clicking and wheels for ChromeOS boot.
+ // When ChromeOS is booted, it hides the mouse cursor but immediate mouse
+ // operation will show the cursor.
+ if (event->type() == ui::ET_MOUSE_MOVED ||
+ event->type() == ui::ET_MOUSE_PRESSED ||
+ event->type() == ui::ET_MOUSEWHEEL) {
+ SetCursorVisibilityOnEvent(window, event, true);
+ UpdateCursor(window, event);
+ }
+
+ ui::EventResult result = FilterMouseEvent(window, event);
+ if ((result & ui::ER_CONSUMED) ||
+ !window_tracker.Contains(window) ||
+ !window->GetRootWindow()) {
+ return result;
+ }
+
+ if (event->type() == ui::ET_MOUSE_PRESSED &&
+ GetActiveWindow(window) != window) {
+ window->GetFocusManager()->SetFocusedWindow(
+ FindFocusableWindowFor(window), event);
+ }
+
+ return result;
+}
+
+ui::EventResult CompoundEventFilter::OnScrollEvent(ui::EventTarget* target,
+ ui::ScrollEvent* event) {
+ return ui::ER_UNHANDLED;
+}
+
+ui::TouchStatus CompoundEventFilter::OnTouchEvent(ui::EventTarget* target,
+ ui::TouchEvent* event) {
+ return EventFilter::OnTouchEvent(target, event);
+}
+
+ui::EventResult CompoundEventFilter::OnGestureEvent(ui::EventTarget* target,
+ ui::GestureEvent* event) {
+ int result = ui::ER_UNHANDLED;
+ if (filters_.might_have_observers()) {
+ ObserverListBase<EventFilter>::Iterator it(filters_);
+ EventFilter* filter;
+ while (!(result & ui::ER_CONSUMED) && (filter = it.GetNext()) != NULL)
+ result |= filter->OnGestureEvent(target, event);
+ }
+
+ Window* window = static_cast<Window*>(target);
+ if (event->type() == ui::ET_GESTURE_BEGIN &&
+ event->details().touch_points() == 1 &&
+ !(result & ui::ER_CONSUMED) &&
+ window->GetRootWindow() &&
+ GetActiveWindow(window) != window) {
+ window->GetFocusManager()->SetFocusedWindow(
+ FindFocusableWindowFor(window), event);
+ }
+
+ return static_cast<ui::EventResult>(result);
+}
+
} // namespace shared
} // namespace aura
diff --git a/ui/aura/shared/compound_event_filter.h b/ui/aura/shared/compound_event_filter.h
index 7ae8e04..deba6eb 100644
--- a/ui/aura/shared/compound_event_filter.h
+++ b/ui/aura/shared/compound_event_filter.h
@@ -50,26 +50,15 @@ class AURA_EXPORT CompoundEventFilter : public EventFilter {
void RemoveFilter(EventFilter* filter);
size_t GetFilterCount() const;
- // Overridden from EventFilter:
- virtual bool PreHandleKeyEvent(Window* target, ui::KeyEvent* event) OVERRIDE;
- virtual bool PreHandleMouseEvent(Window* target,
- ui::MouseEvent* event) OVERRIDE;
- virtual ui::TouchStatus PreHandleTouchEvent(
- Window* target,
- ui::TouchEvent* event) OVERRIDE;
- virtual ui::EventResult PreHandleGestureEvent(
- Window* target,
- ui::GestureEvent* event) OVERRIDE;
-
private:
// Updates the cursor if the target provides a custom one, and provides
// default resize cursors for window edges.
void UpdateCursor(Window* target, ui::MouseEvent* event);
- // Dispatches event to additional filters. Returns false or
- // ui::TOUCH_STATUS_UNKNOWN if event is consumed.
- bool FilterKeyEvent(Window* target, ui::KeyEvent* event);
- bool FilterMouseEvent(Window* target, ui::MouseEvent* event);
+ // Dispatches event to additional filters.
+ ui::EventResult FilterKeyEvent(ui::EventTarget* target, ui::KeyEvent* event);
+ ui::EventResult FilterMouseEvent(ui::EventTarget* target,
+ ui::MouseEvent* event);
ui::TouchStatus FilterTouchEvent(Window* target, ui::TouchEvent* event);
// Sets the visibility of the cursor if the event is not synthesized and
@@ -78,6 +67,21 @@ class AURA_EXPORT CompoundEventFilter : public EventFilter {
ui::LocatedEvent* event,
bool show);
+ // Overridden from EventFilter:
+ virtual ui::TouchStatus PreHandleTouchEvent(Window* target,
+ ui::TouchEvent* event) OVERRIDE;
+
+ // Overridden from ui::EventHandler:
+ virtual ui::EventResult OnKeyEvent(ui::EventTarget* target,
+ ui::KeyEvent* event) OVERRIDE;
+ virtual ui::EventResult OnMouseEvent(ui::EventTarget* target,
+ ui::MouseEvent* event) OVERRIDE;
+ virtual ui::EventResult OnScrollEvent(ui::EventTarget* target,
+ ui::ScrollEvent* event) OVERRIDE;
+ virtual ui::TouchStatus OnTouchEvent(ui::EventTarget* target,
+ ui::TouchEvent* event) OVERRIDE;
+ virtual ui::EventResult OnGestureEvent(ui::EventTarget* target,
+ ui::GestureEvent* e) OVERRIDE;
// Additional event filters that pre-handles events.
ObserverList<EventFilter, true> filters_;
diff --git a/ui/aura/test/test_event_filter.cc b/ui/aura/test/test_event_filter.cc
index ab5210d..87007ad 100644
--- a/ui/aura/test/test_event_filter.cc
+++ b/ui/aura/test/test_event_filter.cc
@@ -11,9 +11,9 @@ TestEventFilter::TestEventFilter()
: key_event_count_(0),
mouse_event_count_(0),
touch_event_count_(0),
- consumes_key_events_(false),
- consumes_mouse_events_(false),
- consumes_touch_events_(false) {
+ key_event_handling_result_(ui::ER_UNHANDLED),
+ mouse_event_handling_result_(ui::ER_UNHANDLED),
+ consumes_touch_event_(false) {
}
TestEventFilter::~TestEventFilter() {
@@ -25,28 +25,32 @@ void TestEventFilter::ResetCounts() {
touch_event_count_ = 0;
}
-bool TestEventFilter::PreHandleKeyEvent(Window* target, ui::KeyEvent* event) {
+ui::EventResult TestEventFilter::OnKeyEvent(ui::EventTarget* target,
+ ui::KeyEvent* event) {
++key_event_count_;
- return consumes_key_events_;
+ return key_event_handling_result_;
}
-bool TestEventFilter::PreHandleMouseEvent(Window* target,
- ui::MouseEvent* event) {
+ui::EventResult TestEventFilter::OnMouseEvent(ui::EventTarget* target,
+ ui::MouseEvent* event) {
++mouse_event_count_;
- return consumes_mouse_events_;
+ return mouse_event_handling_result_;
}
-ui::TouchStatus TestEventFilter::PreHandleTouchEvent(
- Window* target,
- ui::TouchEvent* event) {
+ui::EventResult TestEventFilter::OnScrollEvent(ui::EventTarget* target,
+ ui::ScrollEvent* event) {
+ return ui::ER_UNHANDLED;
+}
+
+ui::TouchStatus TestEventFilter::OnTouchEvent(ui::EventTarget* target,
+ ui::TouchEvent* event) {
++touch_event_count_;
// TODO(sadrul): !
return ui::TOUCH_STATUS_UNKNOWN;
}
-ui::EventResult TestEventFilter::PreHandleGestureEvent(
- Window* target,
- ui::GestureEvent* event) {
+ui::EventResult TestEventFilter::OnGestureEvent(ui::EventTarget* target,
+ ui::GestureEvent* event) {
// TODO(sadrul): !
return ui::ER_UNHANDLED;
}
diff --git a/ui/aura/test/test_event_filter.h b/ui/aura/test/test_event_filter.h
index fe02e9e..1ad7079 100644
--- a/ui/aura/test/test_event_filter.h
+++ b/ui/aura/test/test_event_filter.h
@@ -28,35 +28,35 @@ class TestEventFilter : public EventFilter {
int mouse_event_count() const { return mouse_event_count_; }
int touch_event_count() const { return touch_event_count_; }
- void set_consumes_key_events(bool consumes_key_events) {
- consumes_key_events_ = consumes_key_events;
+ void set_key_event_handling_result(ui::EventResult result) {
+ key_event_handling_result_ = result;
}
- void set_consumes_mouse_events(bool consumes_mouse_events) {
- consumes_mouse_events_ = consumes_mouse_events;
+ void set_mouse_event_handling_result(ui::EventResult result) {
+ mouse_event_handling_result_ = result;
}
- void set_consumes_touch_events(bool consumes_touch_events) {
- consumes_touch_events_ = consumes_touch_events;
+ void set_consumes_touch_events(bool consumes) {
+ consumes_touch_event_ = consumes;
}
- // Overridden from EventFilter:
- virtual bool PreHandleKeyEvent(Window* target, ui::KeyEvent* event) OVERRIDE;
- virtual bool PreHandleMouseEvent(Window* target,
- ui::MouseEvent* event) OVERRIDE;
- virtual ui::TouchStatus PreHandleTouchEvent(
- Window* target,
- ui::TouchEvent* event) OVERRIDE;
- virtual ui::EventResult PreHandleGestureEvent(
- Window* target,
- ui::GestureEvent* event) OVERRIDE;
-
+ // Overridden from ui::EventHandler:
+ virtual ui::EventResult OnKeyEvent(ui::EventTarget* target,
+ ui::KeyEvent* event) OVERRIDE;
+ virtual ui::EventResult OnMouseEvent(ui::EventTarget* target,
+ ui::MouseEvent* event) OVERRIDE;
+ virtual ui::EventResult OnScrollEvent(ui::EventTarget* target,
+ ui::ScrollEvent* event) OVERRIDE;
+ virtual ui::TouchStatus OnTouchEvent(ui::EventTarget* target,
+ ui::TouchEvent* event) OVERRIDE;
+ virtual ui::EventResult OnGestureEvent(ui::EventTarget* target,
+ ui::GestureEvent* event) OVERRIDE;
private:
int key_event_count_;
int mouse_event_count_;
int touch_event_count_;
- bool consumes_key_events_;
- bool consumes_mouse_events_;
- bool consumes_touch_events_;
+ ui::EventResult key_event_handling_result_;
+ ui::EventResult mouse_event_handling_result_;
+ bool consumes_touch_event_;
DISALLOW_COPY_AND_ASSIGN(TestEventFilter);
};
diff --git a/ui/aura/window_delegate.cc b/ui/aura/window_delegate.cc
index b5f7387..ba9c633 100644
--- a/ui/aura/window_delegate.cc
+++ b/ui/aura/window_delegate.cc
@@ -8,12 +8,12 @@ namespace aura {
ui::EventResult WindowDelegate::OnKeyEvent(ui::EventTarget* target,
ui::KeyEvent* event) {
- return OnKeyEvent(event) ? ui::ER_CONSUMED : ui::ER_UNHANDLED;
+ return OnKeyEvent(event) ? ui::ER_HANDLED : ui::ER_UNHANDLED;
}
ui::EventResult WindowDelegate::OnMouseEvent(ui::EventTarget* target,
ui::MouseEvent* event) {
- return OnMouseEvent(event) ? ui::ER_CONSUMED : ui::ER_UNHANDLED;
+ return OnMouseEvent(event) ? ui::ER_HANDLED : ui::ER_UNHANDLED;
}
ui::EventResult WindowDelegate::OnScrollEvent(ui::EventTarget* target,