mac: Add "double-clicked" event for Tray.
This commit is contained in:
parent
ec1db0c7bb
commit
67cbecaba0
6 changed files with 17 additions and 1 deletions
|
@ -36,6 +36,10 @@ void Tray::OnClicked() {
|
|||
Emit("clicked");
|
||||
}
|
||||
|
||||
void Tray::OnDoubleClicked() {
|
||||
Emit("double-clicked");
|
||||
}
|
||||
|
||||
void Tray::SetImage(const gfx::ImageSkia& image) {
|
||||
tray_icon_->SetImage(image);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ class Tray : public mate::EventEmitter,
|
|||
|
||||
// TrayIcon implementations:
|
||||
virtual void OnClicked() OVERRIDE;
|
||||
virtual void OnDoubleClicked() OVERRIDE;
|
||||
|
||||
void SetImage(const gfx::ImageSkia& image);
|
||||
void SetPressedImage(const gfx::ImageSkia& image);
|
||||
|
|
|
@ -22,4 +22,8 @@ void TrayIcon::NotifyClicked() {
|
|||
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked());
|
||||
}
|
||||
|
||||
void TrayIcon::NotifyDoubleClicked() {
|
||||
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDoubleClicked());
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -45,6 +45,7 @@ class TrayIcon {
|
|||
void AddObserver(TrayIconObserver* obs) { observers_.AddObserver(obs); }
|
||||
void RemoveObserver(TrayIconObserver* obs) { observers_.RemoveObserver(obs); }
|
||||
void NotifyClicked();
|
||||
void NotifyDoubleClicked();
|
||||
|
||||
protected:
|
||||
TrayIcon();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
}
|
||||
- (id)initWithIcon:(atom::TrayIconCocoa*)icon;
|
||||
- (void)handleClick:(id)sender;
|
||||
- (void)handleDoubleClick:(id)sender;
|
||||
|
||||
@end // @interface StatusItemController
|
||||
|
||||
|
@ -24,10 +25,13 @@
|
|||
}
|
||||
|
||||
- (void)handleClick:(id)sender {
|
||||
DCHECK(trayIcon_);
|
||||
trayIcon_->NotifyClicked();
|
||||
}
|
||||
|
||||
- (void)handleDoubleClick:(id)sender {
|
||||
trayIcon_->NotifyDoubleClicked();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
namespace atom {
|
||||
|
@ -40,6 +44,7 @@ TrayIconCocoa::TrayIconCocoa() {
|
|||
[item_ setEnabled:YES];
|
||||
[item_ setTarget:controller_];
|
||||
[item_ setAction:@selector(handleClick:)];
|
||||
[item_ setDoubleAction:@selector(handleDoubleClick:)];
|
||||
[item_ setHighlightMode:YES];
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace atom {
|
|||
class TrayIconObserver {
|
||||
public:
|
||||
virtual void OnClicked() {}
|
||||
virtual void OnDoubleClicked() {}
|
||||
|
||||
protected:
|
||||
virtual ~TrayIconObserver() {}
|
||||
|
|
Loading…
Reference in a new issue