refactor: use Get/SetID from views:View in Button (#35022)
This commit is contained in:
parent
08dd38d9be
commit
57c265198e
2 changed files with 4 additions and 4 deletions
|
@ -193,7 +193,7 @@ void MenuBar::ButtonPressed(int id, const ui::Event& event) {
|
||||||
SubmenuButton* source = nullptr;
|
SubmenuButton* source = nullptr;
|
||||||
for (auto* child : children()) {
|
for (auto* child : children()) {
|
||||||
auto* button = static_cast<SubmenuButton*>(child);
|
auto* button = static_cast<SubmenuButton*>(child);
|
||||||
if (button->tag() == id) {
|
if (button->GetID() == id) {
|
||||||
source = button;
|
source = button;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ void MenuBar::RebuildChildren() {
|
||||||
auto* button = new SubmenuButton(
|
auto* button = new SubmenuButton(
|
||||||
base::BindRepeating(&MenuBar::ButtonPressed, base::Unretained(this), i),
|
base::BindRepeating(&MenuBar::ButtonPressed, base::Unretained(this), i),
|
||||||
menu_model_->GetLabelAt(i), background_color_);
|
menu_model_->GetLabelAt(i), background_color_);
|
||||||
button->set_tag(i);
|
button->SetID(i);
|
||||||
AddChildView(button);
|
AddChildView(button);
|
||||||
}
|
}
|
||||||
UpdateViewColors();
|
UpdateViewColors();
|
||||||
|
|
|
@ -34,7 +34,7 @@ void MenuDelegate::RunMenu(ElectronMenuModel* model,
|
||||||
hold_first_switch_ = true;
|
hold_first_switch_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
id_ = button->tag();
|
id_ = button->GetID();
|
||||||
adapter_ = std::make_unique<MenuModelAdapter>(model);
|
adapter_ = std::make_unique<MenuModelAdapter>(model);
|
||||||
|
|
||||||
auto* item = new views::MenuItemView(this);
|
auto* item = new views::MenuItemView(this);
|
||||||
|
@ -127,7 +127,7 @@ views::MenuItemView* MenuDelegate::GetSiblingMenu(
|
||||||
views::MenuButton* button;
|
views::MenuButton* button;
|
||||||
ElectronMenuModel* model;
|
ElectronMenuModel* model;
|
||||||
if (menu_bar_->GetMenuButtonFromScreenPoint(screen_point, &model, &button) &&
|
if (menu_bar_->GetMenuButtonFromScreenPoint(screen_point, &model, &button) &&
|
||||||
button->tag() != id_) {
|
button->GetID() != id_) {
|
||||||
bool switch_in_progress = !!button_to_open_;
|
bool switch_in_progress = !!button_to_open_;
|
||||||
// Always update target to open.
|
// Always update target to open.
|
||||||
button_to_open_ = button;
|
button_to_open_ = button;
|
||||||
|
|
Loading…
Reference in a new issue