}
void Tray::PopUpContextMenu(mate::Arguments* args) {
+ Menu* menu = nullptr;
+ args->GetNext(&menu);
gfx::Point pos;
args->GetNext(&pos);
- tray_icon_->PopUpContextMenu(pos);
+ tray_icon_->PopUpContextMenu(pos, menu ? menu->model() : nullptr);
}
void Tray::SetContextMenu(mate::Arguments* args, Menu* menu) {
const base::string16& contents) {
}
-void TrayIcon::PopUpContextMenu(const gfx::Point& pos) {
+void TrayIcon::PopUpContextMenu(const gfx::Point& pos,
+ ui::SimpleMenuModel* menu_model) {
}
void TrayIcon::NotifyClicked(const gfx::Rect& bounds, int modifiers) {
const base::string16& title,
const base::string16& contents);
- virtual void PopUpContextMenu(const gfx::Point& pos);
+ // Popups the menu.
+ virtual void PopUpContextMenu(const gfx::Point& pos,
+ ui::SimpleMenuModel* menu_model);
// Set the context menu for this icon.
virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) = 0;
void SetToolTip(const std::string& tool_tip) override;
void SetTitle(const std::string& title) override;
void SetHighlightMode(bool highlight) override;
- void PopUpContextMenu(const gfx::Point& pos) override;
+ void PopUpContextMenu(const gfx::Point& pos,
+ ui::SimpleMenuModel* menu_model) override;
void SetContextMenu(ui::SimpleMenuModel* menu_model) override;
protected:
[status_item_view_ setHighlight:highlight];
}
-void TrayIconCocoa::PopUpContextMenu(const gfx::Point& pos) {
+void TrayIconCocoa::PopUpContextMenu(const gfx::Point& pos,
+ ui::SimpleMenuModel* menu_model) {
[status_item_view_ popUpContextMenu];
}
return;
} else if (!double_button_click) { // single right click
if (menu_model_)
- PopUpContextMenu(cursor_pos);
+ PopUpContextMenu(cursor_pos, menu_model_);
else
NotifyRightClicked(gfx::Rect(rect), modifiers);
}
LOG(WARNING) << "Unable to create status tray balloon.";
}
-void NotifyIcon::PopUpContextMenu(const gfx::Point& pos) {
+void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
+ ui::SimpleMenuModel* menu_model) {
// Returns if context menu isn't set.
if (!menu_model_)
return;
void DisplayBalloon(const gfx::Image& icon,
const base::string16& title,
const base::string16& contents) override;
- void PopUpContextMenu(const gfx::Point& pos) override;
+ void PopUpContextMenu(const gfx::Point& pos,
+ ui::SimpleMenuModel* menu_model) override;
void SetContextMenu(ui::SimpleMenuModel* menu_model) override;
private:
Displays a tray balloon.
-### `Tray.popUpContextMenu([position])` _OS X_ _Windows_
+### `Tray.popUpContextMenu([menu, position])` _OS X_ _Windows_
-* `position` Object (optional)- The pop up position.
+* `menu` Menu (optional)
+* `position` Object (optional) - The pop up position.
* `x` Integer
* `y` Integer
+Popups the context menu of tray icon. When `menu` is passed, the `menu` will
+showed instead of the tray's context menu.
+
The `position` is only available on Windows, and it is (0, 0) by default.
### `Tray.setContextMenu(menu)`