summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-29 21:01:33 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-29 21:01:33 +0000
commit80e72e04858a7e06321af9b0d2e5ead968c05d71 (patch)
tree41c388826c5514d9dcbb874a1e268775725df69a /ash
parentadbe467bb7220a7c2acde2469cdaa0dcae742f65 (diff)
downloadchromium_src-80e72e04858a7e06321af9b0d2e5ead968c05d71.zip
chromium_src-80e72e04858a7e06321af9b0d2e5ead968c05d71.tar.gz
chromium_src-80e72e04858a7e06321af9b0d2e5ead968c05d71.tar.bz2
ash: Activate uber-tray and the items on mouse-up instead of on mouse-down.
This change allows the user to move the mouse out of the view after pressing the mouse on it to cancel the action. BUG=129696 TEST=none Review URL: https://chromiumcodereview.appspot.com/10454037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139372 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/date/date_view.cc5
-rw-r--r--ash/system/date/date_view.h3
-rw-r--r--ash/system/tray/tray_views.cc16
-rw-r--r--ash/system/tray/tray_views.h9
4 files changed, 29 insertions, 4 deletions
diff --git a/ash/system/date/date_view.cc b/ash/system/date/date_view.cc
index 71f4394..fe5ef2a 100644
--- a/ash/system/date/date_view.cc
+++ b/ash/system/date/date_view.cc
@@ -160,7 +160,6 @@ TimeView::TimeView()
label_ = CreateLabel();
UpdateTextInternal(base::Time::Now());
AddChildView(label_);
- set_focusable(true);
}
TimeView::~TimeView() {
@@ -182,6 +181,10 @@ bool TimeView::PerformAction(const views::Event& event) {
return false;
}
+bool TimeView::OnMousePressed(const views::MouseEvent& event) {
+ // Let the event fall through.
+ return false;
+}
} // namespace tray
} // namespace internal
diff --git a/ash/system/date/date_view.h b/ash/system/date/date_view.h
index 081ed6f..ab32d02 100644
--- a/ash/system/date/date_view.h
+++ b/ash/system/date/date_view.h
@@ -96,6 +96,9 @@ class TimeView : public BaseDateTimeView {
// Overridden from ActionableView.
virtual bool PerformAction(const views::Event& event) OVERRIDE;
+ // Overridden from views::View.
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+
views::Label* label_;
base::HourClockType hour_type_;
diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc
index b540700..5418fa3 100644
--- a/ash/system/tray/tray_views.cc
+++ b/ash/system/tray/tray_views.cc
@@ -60,7 +60,8 @@ gfx::Size FixedSizedImageView::GetPreferredSize() {
////////////////////////////////////////////////////////////////////////////////
// ActionableView
-ActionableView::ActionableView() {
+ActionableView::ActionableView()
+ : has_capture_(false) {
set_focusable(true);
}
@@ -76,7 +77,18 @@ bool ActionableView::OnKeyPressed(const views::KeyEvent& event) {
}
bool ActionableView::OnMousePressed(const views::MouseEvent& event) {
- return PerformAction(event);
+ // Return true so that this view starts capturing the events.
+ has_capture_ = true;
+ return true;
+}
+
+void ActionableView::OnMouseReleased(const views::MouseEvent& event) {
+ if (has_capture_ && GetLocalBounds().Contains(event.location()))
+ PerformAction(event);
+}
+
+void ActionableView::OnMouseCaptureLost() {
+ has_capture_ = false;
}
void ActionableView::SetAccessibleName(const string16& name) {
diff --git a/ash/system/tray/tray_views.h b/ash/system/tray/tray_views.h
index ba5534f..f6173b2 100644
--- a/ash/system/tray/tray_views.h
+++ b/ash/system/tray/tray_views.h
@@ -44,7 +44,11 @@ class FixedSizedImageView : public views::ImageView {
};
// A focusable view that performs an action when user clicks on it, or presses
-// enter or space when focused. Exported for SystemTray.
+// enter or space when focused. Note that the action is triggered on mouse-up,
+// instead of on mouse-down. So if user presses the mouse on the view, then
+// moves the mouse out of the view and then releases, then the action will not
+// be performed.
+// Exported for SystemTray.
class ASH_EXPORT ActionableView : public views::View {
public:
ActionableView();
@@ -64,11 +68,14 @@ class ASH_EXPORT ActionableView : public views::View {
// Overridden from views::View.
virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE;
virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
+ virtual void OnMouseCaptureLost() OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
private:
string16 accessible_name_;
+ bool has_capture_;
DISALLOW_COPY_AND_ASSIGN(ActionableView);
};