diff options
Diffstat (limited to 'ui/views/events')
-rw-r--r-- | ui/views/events/event.cc | 2 | ||||
-rw-r--r-- | ui/views/events/event.h | 3 | ||||
-rw-r--r-- | ui/views/events/focus_event.cc | 19 | ||||
-rw-r--r-- | ui/views/events/focus_event.h | 51 |
4 files changed, 73 insertions, 2 deletions
diff --git a/ui/views/events/event.cc b/ui/views/events/event.cc index f1d04b9..a6da13b 100644 --- a/ui/views/events/event.cc +++ b/ui/views/events/event.cc @@ -54,4 +54,4 @@ MouseEvent::MouseEvent(const MouseEvent& other, View* source, View* target) : LocatedEvent(other, source, target) { } -} // namespace views +} // namespace ui diff --git a/ui/views/events/event.h b/ui/views/events/event.h index d8ad17f..c3cbce0 100644 --- a/ui/views/events/event.h +++ b/ui/views/events/event.h @@ -30,7 +30,8 @@ class Event { ET_KEY_PRESSED, ET_KEY_RELEASED, ET_MOUSEWHEEL, - ET_DROP_TARGET_EVENT }; + ET_DROP_TARGET_EVENT, + ET_FOCUS_CHANGE }; // Event flags currently supported. Although this is a "views" // file, this header is used on non-views platforms (e.g. OSX). For diff --git a/ui/views/events/focus_event.cc b/ui/views/events/focus_event.cc new file mode 100644 index 0000000..4a05999 --- /dev/null +++ b/ui/views/events/focus_event.cc @@ -0,0 +1,19 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/views/events/focus_event.h" + +namespace ui { + +//////////////////////////////////////////////////////////////////////////////// +// FocusEvent, public: + +FocusEvent::FocusEvent(Type type, Reason reason, TraversalDirection direction) + : type_(type), + reason_(reason), + direction_(direction), + Event(ET_FOCUS_CHANGE, 0) { +} + +} // namespace ui diff --git a/ui/views/events/focus_event.h b/ui/views/events/focus_event.h new file mode 100644 index 0000000..377c3f7 --- /dev/null +++ b/ui/views/events/focus_event.h @@ -0,0 +1,51 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_EVENTS_FOCUS_EVENT_H_ +#define UI_VIEWS_EVENTS_FOCUS_EVENT_H_ +#pragma once + +#include "base/basictypes.h" +#include "ui/views/events/event.h" + +namespace ui { + +class FocusEvent : public Event { + public: + enum Type { + TYPE_FOCUS_IN, // Target View did gain focus + TYPE_FOCUS_OUT // Target View will lose focus + }; + + enum Reason { + REASON_TRAVERSAL, // Focus change occurred because of a tab-traversal + REASON_RESTORE, // Focus was restored (e.g. window activation). + REASON_DIRECT // Focus was directly set (e.g. with mouse click). + }; + + enum TraversalDirection { + DIRECTION_NONE, + DIRECTION_FORWARD, + DIRECTION_REVERSE + }; + + FocusEvent(Type type, + Reason reason, + TraversalDirection direction); + + Type type() const { return type_; } + Reason reason() const { return reason_; } + TraversalDirection direction() const { return direction_; } + + private: + Type type_; + Reason reason_; + TraversalDirection direction_; + + DISALLOW_COPY_AND_ASSIGN(FocusEvent); +}; + +} // namespace ui + +#endif // UI_VIEWS_EVENTS_FOCUS_EVENT_H_ |