Tray: Add drag-entered and drag-exited events
This commit is contained in:
parent
5b0ea5bd46
commit
818892d474
6 changed files with 27 additions and 0 deletions
|
@ -78,6 +78,14 @@ void Tray::OnDropFiles(const std::vector<std::string>& files) {
|
||||||
Emit("drop-files", files);
|
Emit("drop-files", files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Tray::OnDragEntered() {
|
||||||
|
Emit("drag-entered");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tray::OnDragExited() {
|
||||||
|
Emit("drag-exited");
|
||||||
|
}
|
||||||
|
|
||||||
bool Tray::IsDestroyed() const {
|
bool Tray::IsDestroyed() const {
|
||||||
return !tray_icon_;
|
return !tray_icon_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,8 @@ class Tray : public mate::TrackableObject<Tray>,
|
||||||
void OnBalloonClicked() override;
|
void OnBalloonClicked() override;
|
||||||
void OnBalloonClosed() override;
|
void OnBalloonClosed() override;
|
||||||
void OnDropFiles(const std::vector<std::string>& files) override;
|
void OnDropFiles(const std::vector<std::string>& files) override;
|
||||||
|
void OnDragEntered() override;
|
||||||
|
void OnDragExited() override;
|
||||||
|
|
||||||
// mate::Wrappable:
|
// mate::Wrappable:
|
||||||
bool IsDestroyed() const override;
|
bool IsDestroyed() const override;
|
||||||
|
|
|
@ -59,4 +59,12 @@ void TrayIcon::NotifyDropFiles(const std::vector<std::string>& files) {
|
||||||
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDropFiles(files));
|
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDropFiles(files));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrayIcon::NotifyDragEntered() {
|
||||||
|
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragEntered());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrayIcon::NotifyDragExited() {
|
||||||
|
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragExited());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -62,6 +62,8 @@ class TrayIcon {
|
||||||
void NotifyRightClicked(const gfx::Rect& bounds = gfx::Rect(),
|
void NotifyRightClicked(const gfx::Rect& bounds = gfx::Rect(),
|
||||||
int modifiers = 0);
|
int modifiers = 0);
|
||||||
void NotifyDropFiles(const std::vector<std::string>& files);
|
void NotifyDropFiles(const std::vector<std::string>& files);
|
||||||
|
void TrayIcon::NotifyDragEntered();
|
||||||
|
void TrayIcon::NotifyDragExited();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TrayIcon();
|
TrayIcon();
|
||||||
|
|
|
@ -254,9 +254,14 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
|
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
|
||||||
|
trayIcon_->NotifyDragEntered();
|
||||||
return NSDragOperationCopy;
|
return NSDragOperationCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)draggingExited:(id <NSDraggingInfo>)sender {
|
||||||
|
trayIcon_->NotifyDragExited();
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
|
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
|
||||||
NSPasteboard* pboard = [sender draggingPasteboard];
|
NSPasteboard* pboard = [sender draggingPasteboard];
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ class TrayIconObserver {
|
||||||
virtual void OnBalloonClosed() {}
|
virtual void OnBalloonClosed() {}
|
||||||
virtual void OnRightClicked(const gfx::Rect& bounds, int modifiers) {}
|
virtual void OnRightClicked(const gfx::Rect& bounds, int modifiers) {}
|
||||||
virtual void OnDropFiles(const std::vector<std::string>& files) {}
|
virtual void OnDropFiles(const std::vector<std::string>& files) {}
|
||||||
|
virtual void OnDragEntered() {}
|
||||||
|
virtual void OnDragExited() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~TrayIconObserver() {}
|
virtual ~TrayIconObserver() {}
|
||||||
|
|
Loading…
Reference in a new issue