add getter for ignoreDoubleClickEvents field

This commit is contained in:
mikeykhalil 2018-05-03 00:43:46 -07:00
parent 208374afa4
commit 94ffd4bfc0
6 changed files with 27 additions and 7 deletions

View file

@ -182,6 +182,14 @@ void Tray::SetIgnoreDoubleClickEvents(bool ignore) {
#endif #endif
} }
bool Tray::GetIgnoreDoubleClickEvents() {
#if defined(OS_MACOSX)
return tray_icon_->GetIgnoreDoubleClickEvents();
#else
return false;
#endif
}
void Tray::DisplayBalloon(mate::Arguments* args, void Tray::DisplayBalloon(mate::Arguments* args,
const mate::Dictionary& options) { const mate::Dictionary& options) {
mate::Handle<NativeImage> icon; mate::Handle<NativeImage> icon;
@ -232,6 +240,8 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setHighlightMode", &Tray::SetHighlightMode) .SetMethod("setHighlightMode", &Tray::SetHighlightMode)
.SetMethod("setIgnoreDoubleClickEvents", .SetMethod("setIgnoreDoubleClickEvents",
&Tray::SetIgnoreDoubleClickEvents) &Tray::SetIgnoreDoubleClickEvents)
.SetMethod("getIgnoreDoubleClickEvents",
&Tray::GetIgnoreDoubleClickEvents)
.SetMethod("displayBalloon", &Tray::DisplayBalloon) .SetMethod("displayBalloon", &Tray::DisplayBalloon)
.SetMethod("popUpContextMenu", &Tray::PopUpContextMenu) .SetMethod("popUpContextMenu", &Tray::PopUpContextMenu)
.SetMethod("setContextMenu", &Tray::SetContextMenu) .SetMethod("setContextMenu", &Tray::SetContextMenu)

View file

@ -71,6 +71,7 @@ class Tray : public mate::TrackableObject<Tray>, public TrayIconObserver {
void SetTitle(const std::string& title); void SetTitle(const std::string& title);
void SetHighlightMode(TrayIcon::HighlightMode mode); void SetHighlightMode(TrayIcon::HighlightMode mode);
void SetIgnoreDoubleClickEvents(bool ignore); void SetIgnoreDoubleClickEvents(bool ignore);
bool GetIgnoreDoubleClickEvents();
void DisplayBalloon(mate::Arguments* args, const mate::Dictionary& options); void DisplayBalloon(mate::Arguments* args, const mate::Dictionary& options);
void PopUpContextMenu(mate::Arguments* args); void PopUpContextMenu(mate::Arguments* args);
void SetContextMenu(v8::Isolate* isolate, mate::Handle<Menu> menu); void SetContextMenu(v8::Isolate* isolate, mate::Handle<Menu> menu);

View file

@ -16,9 +16,6 @@ void TrayIcon::SetTitle(const std::string& title) {}
void TrayIcon::SetHighlightMode(TrayIcon::HighlightMode mode) {} void TrayIcon::SetHighlightMode(TrayIcon::HighlightMode mode) {}
void TrayIcon::SetIgnoreDoubleClickEvents(bool ignore) {
}
void TrayIcon::DisplayBalloon(ImageType icon, void TrayIcon::DisplayBalloon(ImageType icon,
const base::string16& title, const base::string16& title,
const base::string16& contents) {} const base::string16& contents) {}

View file

@ -51,9 +51,12 @@ class TrayIcon {
}; };
virtual void SetHighlightMode(HighlightMode mode); virtual void SetHighlightMode(HighlightMode mode);
// Sets the flag which determines whether to ignore double click events. This // Setter and getter for the flag which determines whether to ignore double
// only works on macOS. // click events. These only work on macOS.
virtual void SetIgnoreDoubleClickEvents(bool ignore); #if defined(OS_MACOSX)
virtual void SetIgnoreDoubleClickEvents(bool ignore) = 0;
virtual bool GetIgnoreDoubleClickEvents() = 0;
#endif
// Displays a notification balloon with the specified contents. // Displays a notification balloon with the specified contents.
// Depending on the platform it might not appear by the icon tray. // Depending on the platform it might not appear by the icon tray.

View file

@ -28,6 +28,7 @@ class TrayIconCocoa : public TrayIcon, public AtomMenuModel::Observer {
void SetTitle(const std::string& title) override; void SetTitle(const std::string& title) override;
void SetHighlightMode(TrayIcon::HighlightMode mode) override; void SetHighlightMode(TrayIcon::HighlightMode mode) override;
void SetIgnoreDoubleClickEvents(bool ignore) override; void SetIgnoreDoubleClickEvents(bool ignore) override;
bool GetIgnoreDoubleClickEvents() override;
void PopUpContextMenu(const gfx::Point& pos, void PopUpContextMenu(const gfx::Point& pos,
AtomMenuModel* menu_model) override; AtomMenuModel* menu_model) override;
void SetContextMenu(AtomMenuModel* menu_model) override; void SetContextMenu(AtomMenuModel* menu_model) override;

View file

@ -206,10 +206,14 @@ const CGFloat kVerticalTitleMargin = 2;
[self setNeedsDisplay:YES]; [self setNeedsDisplay:YES];
} }
- (void) setIgnoreDoubleClickEvents:(BOOL)ignore { - (void)setIgnoreDoubleClickEvents:(BOOL)ignore {
ignoreDoubleClickEvents_ = ignore; ignoreDoubleClickEvents_ = ignore;
} }
- (BOOL)getIgnoreDoubleClickEvents {
return ignoreDoubleClickEvents_;
}
- (void)setTitle:(NSString*)title { - (void)setTitle:(NSString*)title {
if (title.length > 0) { if (title.length > 0) {
title_.reset([title copy]); title_.reset([title copy]);
@ -450,6 +454,10 @@ void TrayIconCocoa::SetIgnoreDoubleClickEvents(bool ignore) {
[status_item_view_ setIgnoreDoubleClickEvents:ignore]; [status_item_view_ setIgnoreDoubleClickEvents:ignore];
} }
bool TrayIconCocoa::GetIgnoreDoubleClickEvents() {
return [status_item_view_ getIgnoreDoubleClickEvents];
}
void TrayIconCocoa::PopUpContextMenu(const gfx::Point& pos, void TrayIconCocoa::PopUpContextMenu(const gfx::Point& pos,
AtomMenuModel* menu_model) { AtomMenuModel* menu_model) {
[status_item_view_ popUpContextMenu:menu_model]; [status_item_view_ popUpContextMenu:menu_model];