diff options
Diffstat (limited to 'views/controls/button')
-rw-r--r-- | views/controls/button/button_dropdown.cc | 13 | ||||
-rw-r--r-- | views/controls/button/button_dropdown.h | 4 | ||||
-rw-r--r-- | views/controls/button/checkbox.cc | 10 | ||||
-rw-r--r-- | views/controls/button/checkbox.h | 3 | ||||
-rw-r--r-- | views/controls/button/custom_button.cc | 13 | ||||
-rw-r--r-- | views/controls/button/custom_button.h | 3 | ||||
-rw-r--r-- | views/controls/button/image_button.h | 6 | ||||
-rw-r--r-- | views/controls/button/menu_button.cc | 8 | ||||
-rw-r--r-- | views/controls/button/menu_button.h | 2 | ||||
-rw-r--r-- | views/controls/button/radio_button.cc | 12 | ||||
-rw-r--r-- | views/controls/button/radio_button.h | 8 |
11 files changed, 47 insertions, 35 deletions
diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc index c2da598..7afdbd5 100644 --- a/views/controls/button/button_dropdown.cc +++ b/views/controls/button/button_dropdown.cc @@ -73,17 +73,12 @@ bool ButtonDropDown::OnMouseDragged(const MouseEvent& event) { return result; } -void ButtonDropDown::OnMouseReleased(const MouseEvent& event, bool canceled) { - // Showing the drop down results in a MouseReleased with a canceled drag, we - // need to ignore it. - if (!canceled && (IsTriggerableEvent(event) || - (event.IsRightMouseButton() && !HitTest(event.location())))) { - ImageButton::OnMouseReleased(event, canceled); +void ButtonDropDown::OnMouseReleased(const MouseEvent& event) { + if (IsTriggerableEvent(event) || + (event.IsRightMouseButton() && !HitTest(event.location()))) { + ImageButton::OnMouseReleased(event); } - if (canceled) - return; - if (IsTriggerableEvent(event)) show_menu_factory_.RevokeAll(); diff --git a/views/controls/button/button_dropdown.h b/views/controls/button/button_dropdown.h index 0a62584..9e8785c 100644 --- a/views/controls/button/button_dropdown.h +++ b/views/controls/button/button_dropdown.h @@ -28,7 +28,9 @@ class ButtonDropDown : public ImageButton { // Overridden from views::View virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; - virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; + // Showing the drop down results in a MouseCaptureLost, we need to ignore it. + virtual void OnMouseCaptureLost() OVERRIDE {} virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; // Display the right-click menu, as triggered by the keyboard, for instance. // Using the member function ShowDropDownMenu for the actual display. diff --git a/views/controls/button/checkbox.cc b/views/controls/button/checkbox.cc index 693e282..0cb01f6 100644 --- a/views/controls/button/checkbox.cc +++ b/views/controls/button/checkbox.cc @@ -131,14 +131,18 @@ bool Checkbox::OnMouseDragged(const MouseEvent& event) { return false; } -void Checkbox::OnMouseReleased(const MouseEvent& event, bool canceled) { - native_wrapper_->SetPushed(false); - if (!canceled && HitTestLabel(event)) { +void Checkbox::OnMouseReleased(const MouseEvent& event) { + OnMouseCaptureLost(); + if (HitTestLabel(event)) { SetChecked(!checked()); ButtonPressed(); } } +void Checkbox::OnMouseCaptureLost() { + native_wrapper_->SetPushed(false); +} + void Checkbox::OnMouseMoved(const MouseEvent& event) { native_wrapper_->SetPushed(HitTestLabel(event)); } diff --git a/views/controls/button/checkbox.h b/views/controls/button/checkbox.h index 19491e9..4451217 100644 --- a/views/controls/button/checkbox.h +++ b/views/controls/button/checkbox.h @@ -49,7 +49,8 @@ class Checkbox : public NativeButton { virtual std::string GetClassName() const OVERRIDE; virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; - virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; + virtual void OnMouseCaptureLost() OVERRIDE; virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc index 5f8e82e..55acba8 100644 --- a/views/controls/button/custom_button.cc +++ b/views/controls/button/custom_button.cc @@ -129,9 +129,8 @@ bool CustomButton::OnMouseDragged(const MouseEvent& event) { return true; } -void CustomButton::OnMouseReleased(const MouseEvent& event, bool canceled) { - // Starting a drag results in a MouseReleased, we need to ignore it. - if ((state_ == BS_DISABLED) || InDrag()) +void CustomButton::OnMouseReleased(const MouseEvent& event) { + if (state_ == BS_DISABLED) return; if (!HitTest(event.location())) { @@ -140,13 +139,19 @@ void CustomButton::OnMouseReleased(const MouseEvent& event, bool canceled) { } SetState(BS_HOT); - if (!canceled && IsTriggerableEvent(event)) { + if (IsTriggerableEvent(event)) { NotifyClick(event); // NOTE: We may be deleted at this point (by the listener's notification // handler). } } +void CustomButton::OnMouseCaptureLost() { + // Starting a drag results in a MouseCaptureLost, we need to ignore it. + if (state_ != BS_DISABLED && !InDrag()) + SetState(BS_NORMAL); +} + void CustomButton::OnMouseEntered(const MouseEvent& event) { if (state_ != BS_DISABLED) SetState(BS_HOT); diff --git a/views/controls/button/custom_button.h b/views/controls/button/custom_button.h index 8b4008c..b898483 100644 --- a/views/controls/button/custom_button.h +++ b/views/controls/button/custom_button.h @@ -80,7 +80,8 @@ class CustomButton : public Button, virtual std::string GetClassName() const OVERRIDE; virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; - virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; + virtual void OnMouseCaptureLost() OVERRIDE; virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; diff --git a/views/controls/button/image_button.h b/views/controls/button/image_button.h index 7ac6a29..1b09d5f 100644 --- a/views/controls/button/image_button.h +++ b/views/controls/button/image_button.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -43,8 +43,8 @@ class ImageButton : public CustomButton { VerticalAlignment v_align); // Overridden from View: - virtual gfx::Size GetPreferredSize(); - virtual void OnPaint(gfx::Canvas* canvas); + virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; // Sets preferred size, so it could be correctly positioned in layout even if // it is NULL. diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc index 3ada964..3451434 100644 --- a/views/controls/button/menu_button.cc +++ b/views/controls/button/menu_button.cc @@ -198,17 +198,17 @@ bool MenuButton::OnMousePressed(const MouseEvent& event) { return true; } -void MenuButton::OnMouseReleased(const MouseEvent& event, bool canceled) { +void MenuButton::OnMouseReleased(const MouseEvent& event) { // Explicitly test for left mouse button to show the menu. If we tested for // !IsTriggerableEvent it could lead to a situation where we end up showing // the menu and context menu (this would happen if the right button is not // triggerable and there's a context menu). if (GetDragOperations(event.location()) != ui::DragDropTypes::DRAG_NONE && - state() != BS_DISABLED && !canceled && !InDrag() && - event.IsOnlyLeftMouseButton() && HitTest(event.location())) { + state() != BS_DISABLED && !InDrag() && event.IsOnlyLeftMouseButton() && + HitTest(event.location())) { Activate(); } else { - TextButton::OnMouseReleased(event, canceled); + TextButton::OnMouseReleased(event); } } diff --git a/views/controls/button/menu_button.h b/views/controls/button/menu_button.h index b564b1c..edab18b 100644 --- a/views/controls/button/menu_button.h +++ b/views/controls/button/menu_button.h @@ -55,7 +55,7 @@ class MenuButton : public TextButton { virtual gfx::Size GetPreferredSize() OVERRIDE; virtual std::string GetClassName() const OVERRIDE; virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; - virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE; virtual bool OnKeyReleased(const KeyEvent& event) OVERRIDE; diff --git a/views/controls/button/radio_button.cc b/views/controls/button/radio_button.cc index f162f2c..46133be 100644 --- a/views/controls/button/radio_button.cc +++ b/views/controls/button/radio_button.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -87,13 +87,17 @@ bool RadioButton::IsGroupFocusTraversable() const { return false; } -void RadioButton::OnMouseReleased(const MouseEvent& event, bool canceled) { - native_wrapper_->SetPushed(false); +void RadioButton::OnMouseReleased(const MouseEvent& event) { // Set the checked state to true only if we are unchecked, since we can't // be toggled on and off like a checkbox. - if (!checked() && !canceled && HitTestLabel(event)) + if (!checked() && HitTestLabel(event)) SetChecked(true); + OnMouseCaptureLost(); +} + +void RadioButton::OnMouseCaptureLost() { + native_wrapper_->SetPushed(false); ButtonPressed(); } diff --git a/views/controls/button/radio_button.h b/views/controls/button/radio_button.h index 5ff6f76..7df8387 100644 --- a/views/controls/button/radio_button.h +++ b/views/controls/button/radio_button.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -28,15 +28,15 @@ class RadioButton : public Checkbox { virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; virtual View* GetSelectedViewForGroup(int group_id) OVERRIDE; virtual bool IsGroupFocusTraversable() const OVERRIDE; - virtual void OnMouseReleased(const MouseEvent& event, bool canceled) - OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; + virtual void OnMouseCaptureLost() OVERRIDE; protected: // Overridden from View: virtual std::string GetClassName() const OVERRIDE; // Overridden from NativeButton: - virtual NativeButtonWrapper* CreateWrapper(); + virtual NativeButtonWrapper* CreateWrapper() OVERRIDE; private: friend class NativeRadioButtonGtk; |