Add menu
parameter for Tray.popUpContextMenu
This commit is contained in:
parent
202475f5a9
commit
2fba05b5e7
8 changed files with 23 additions and 10 deletions
|
@ -137,9 +137,11 @@ void Tray::DisplayBalloon(mate::Arguments* args,
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tray::PopUpContextMenu(mate::Arguments* args) {
|
void Tray::PopUpContextMenu(mate::Arguments* args) {
|
||||||
|
Menu* menu = nullptr;
|
||||||
|
args->GetNext(&menu);
|
||||||
gfx::Point pos;
|
gfx::Point pos;
|
||||||
args->GetNext(&pos);
|
args->GetNext(&pos);
|
||||||
tray_icon_->PopUpContextMenu(pos);
|
tray_icon_->PopUpContextMenu(pos, menu ? menu->model() : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tray::SetContextMenu(mate::Arguments* args, Menu* menu) {
|
void Tray::SetContextMenu(mate::Arguments* args, Menu* menu) {
|
||||||
|
|
|
@ -26,7 +26,8 @@ void TrayIcon::DisplayBalloon(const gfx::Image& icon,
|
||||||
const base::string16& contents) {
|
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) {
|
void TrayIcon::NotifyClicked(const gfx::Rect& bounds, int modifiers) {
|
||||||
|
|
|
@ -47,7 +47,9 @@ class TrayIcon {
|
||||||
const base::string16& title,
|
const base::string16& title,
|
||||||
const base::string16& contents);
|
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.
|
// Set the context menu for this icon.
|
||||||
virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) = 0;
|
virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) = 0;
|
||||||
|
|
|
@ -29,7 +29,8 @@ class TrayIconCocoa : public TrayIcon,
|
||||||
void SetToolTip(const std::string& tool_tip) override;
|
void SetToolTip(const std::string& tool_tip) override;
|
||||||
void SetTitle(const std::string& title) override;
|
void SetTitle(const std::string& title) override;
|
||||||
void SetHighlightMode(bool highlight) 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;
|
void SetContextMenu(ui::SimpleMenuModel* menu_model) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -338,7 +338,8 @@ void TrayIconCocoa::SetHighlightMode(bool highlight) {
|
||||||
[status_item_view_ setHighlight:highlight];
|
[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];
|
[status_item_view_ popUpContextMenu];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos,
|
||||||
return;
|
return;
|
||||||
} else if (!double_button_click) { // single right click
|
} else if (!double_button_click) { // single right click
|
||||||
if (menu_model_)
|
if (menu_model_)
|
||||||
PopUpContextMenu(cursor_pos);
|
PopUpContextMenu(cursor_pos, menu_model_);
|
||||||
else
|
else
|
||||||
NotifyRightClicked(gfx::Rect(rect), modifiers);
|
NotifyRightClicked(gfx::Rect(rect), modifiers);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,8 @@ void NotifyIcon::DisplayBalloon(const gfx::Image& icon,
|
||||||
LOG(WARNING) << "Unable to create status tray balloon.";
|
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.
|
// Returns if context menu isn't set.
|
||||||
if (!menu_model_)
|
if (!menu_model_)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -52,7 +52,8 @@ class NotifyIcon : public TrayIcon {
|
||||||
void DisplayBalloon(const gfx::Image& icon,
|
void DisplayBalloon(const gfx::Image& icon,
|
||||||
const base::string16& title,
|
const base::string16& title,
|
||||||
const base::string16& contents) override;
|
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;
|
void SetContextMenu(ui::SimpleMenuModel* menu_model) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -187,12 +187,16 @@ when the tray icon is clicked. Defaults to true.
|
||||||
|
|
||||||
Displays a tray balloon.
|
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
|
* `x` Integer
|
||||||
* `y` 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.
|
The `position` is only available on Windows, and it is (0, 0) by default.
|
||||||
|
|
||||||
### `Tray.setContextMenu(menu)`
|
### `Tray.setContextMenu(menu)`
|
||||||
|
|
Loading…
Reference in a new issue