feat: add tray.closeContextMenu() (#21807)
This commit is contained in:
parent
87af95be3e
commit
b90537a629
10 changed files with 45 additions and 2 deletions
|
@ -199,8 +199,7 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
|
|||
return;
|
||||
|
||||
// Cancel current menu if there is one.
|
||||
if (menu_runner_ && menu_runner_->IsRunning())
|
||||
menu_runner_->Cancel();
|
||||
CloseContextMenu();
|
||||
|
||||
// Show menu at mouse's position by default.
|
||||
gfx::Rect rect(pos, gfx::Size());
|
||||
|
@ -231,6 +230,12 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
|
|||
ui::MENU_SOURCE_MOUSE);
|
||||
}
|
||||
|
||||
void NotifyIcon::CloseContextMenu() {
|
||||
if (menu_runner_ && menu_runner_->IsRunning()) {
|
||||
menu_runner_->Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyIcon::SetContextMenu(AtomMenuModel* menu_model) {
|
||||
menu_model_ = menu_model;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ class NotifyIcon : public TrayIcon {
|
|||
void Focus() override;
|
||||
void PopUpContextMenu(const gfx::Point& pos,
|
||||
AtomMenuModel* menu_model) override;
|
||||
void CloseContextMenu() override;
|
||||
void SetContextMenu(AtomMenuModel* menu_model) override;
|
||||
gfx::Rect GetBounds() override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue