Commit ef5c7aee authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

[Extensions Toolbar Views] Override ShouldEnterPushedState in ToolbarActionView

crrev.com/48bb4848 introduced a new behavior
for menu buttons where they don't enter pushed state if they can be dragged.
Since ToolbarActionView emulates either a LabelButton or a MenuButton depending
whether it has a popup, it should override this.

BUG=458041

Review URL: https://codereview.chromium.org/935163002

Cr-Commit-Position: refs/heads/master@{#317435}
parent 103bf194
......@@ -229,6 +229,12 @@ scoped_ptr<LabelButtonBorder> ToolbarActionView::CreateDefaultBorder() const {
return border.Pass();
}
bool ToolbarActionView::ShouldEnterPushedState(const ui::Event& event) {
return view_controller_->HasPopup(GetCurrentWebContents()) ?
MenuButton::ShouldEnterPushedState(event) :
LabelButton::ShouldEnterPushedState(event);
}
gfx::ImageSkia ToolbarActionView::GetIconForTest() {
return GetImage(views::Button::STATE_NORMAL);
}
......
......@@ -87,6 +87,10 @@ class ToolbarActionView : public views::MenuButton,
// behavior. MenuButton has the notion of a child popup being shown where the
// button will stay in the pushed state until the "menu" (a popup in this
// case) is dismissed.
// TODO(devlin): This is a good idea, but it has some funny UI side-effects,
// like the fact that label buttons enter a pressed state immediately, but
// menu buttons only enter a pressed state on release (if they're draggable).
// We should probably just pick a behavior, and stick to it.
bool Activate() override;
bool OnMousePressed(const ui::MouseEvent& event) override;
void OnMouseReleased(const ui::MouseEvent& event) override;
......@@ -94,6 +98,7 @@ class ToolbarActionView : public views::MenuButton,
bool OnKeyReleased(const ui::KeyEvent& event) override;
void OnGestureEvent(ui::GestureEvent* event) override;
scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override;
bool ShouldEnterPushedState(const ui::Event& event) override;
// ToolbarActionViewDelegate: (public because called by others).
void UpdateState() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment