Tray: Add drag-end and drop events
This commit is contained in:
parent
f98147ea01
commit
d1e8e71e3f
6 changed files with 31 additions and 0 deletions
|
@ -74,6 +74,10 @@ void Tray::OnBalloonClosed() {
|
|||
Emit("balloon-closed");
|
||||
}
|
||||
|
||||
void Tray::OnDrop() {
|
||||
Emit("drop");
|
||||
}
|
||||
|
||||
void Tray::OnDropFiles(const std::vector<std::string>& files) {
|
||||
Emit("drop-files", files);
|
||||
}
|
||||
|
@ -86,6 +90,10 @@ void Tray::OnDragExited() {
|
|||
Emit("drag-leave");
|
||||
}
|
||||
|
||||
void Tray::OnDragEnded() {
|
||||
Emit("drag-end");
|
||||
}
|
||||
|
||||
bool Tray::IsDestroyed() const {
|
||||
return !tray_icon_;
|
||||
}
|
||||
|
|
|
@ -48,9 +48,11 @@ class Tray : public mate::TrackableObject<Tray>,
|
|||
void OnBalloonShow() override;
|
||||
void OnBalloonClicked() override;
|
||||
void OnBalloonClosed() override;
|
||||
void OnDrop() override;
|
||||
void OnDropFiles(const std::vector<std::string>& files) override;
|
||||
void OnDragEntered() override;
|
||||
void OnDragExited() override;
|
||||
void OnDragEnded() override;
|
||||
|
||||
// mate::Wrappable:
|
||||
bool IsDestroyed() const override;
|
||||
|
|
|
@ -55,6 +55,10 @@ void TrayIcon::NotifyRightClicked(const gfx::Rect& bounds, int modifiers) {
|
|||
OnRightClicked(bounds, modifiers));
|
||||
}
|
||||
|
||||
void TrayIcon::NotifyDrop() {
|
||||
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDrop());
|
||||
}
|
||||
|
||||
void TrayIcon::NotifyDropFiles(const std::vector<std::string>& files) {
|
||||
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDropFiles(files));
|
||||
}
|
||||
|
@ -67,4 +71,8 @@ void TrayIcon::NotifyDragExited() {
|
|||
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragExited());
|
||||
}
|
||||
|
||||
void TrayIcon::NotifyDragEnded() {
|
||||
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragEnded());
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -61,9 +61,11 @@ class TrayIcon {
|
|||
void NotifyBalloonClosed();
|
||||
void NotifyRightClicked(const gfx::Rect& bounds = gfx::Rect(),
|
||||
int modifiers = 0);
|
||||
void NotifyDrop();
|
||||
void NotifyDropFiles(const std::vector<std::string>& files);
|
||||
void NotifyDragEntered();
|
||||
void NotifyDragExited();
|
||||
void NotifyDragEnded();
|
||||
|
||||
protected:
|
||||
TrayIcon();
|
||||
|
|
|
@ -262,6 +262,15 @@ const CGFloat kVerticalTitleMargin = 2;
|
|||
trayIcon_->NotifyDragExited();
|
||||
}
|
||||
|
||||
- (void)draggingEnded:(id <NSDraggingInfo>)sender {
|
||||
trayIcon_->NotifyDragEnded();
|
||||
}
|
||||
|
||||
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender {
|
||||
trayIcon_->NotifyDrop();
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
|
||||
NSPasteboard* pboard = [sender draggingPasteboard];
|
||||
|
||||
|
|
|
@ -22,9 +22,11 @@ class TrayIconObserver {
|
|||
virtual void OnBalloonClicked() {}
|
||||
virtual void OnBalloonClosed() {}
|
||||
virtual void OnRightClicked(const gfx::Rect& bounds, int modifiers) {}
|
||||
virtual void OnDrop() {}
|
||||
virtual void OnDropFiles(const std::vector<std::string>& files) {}
|
||||
virtual void OnDragEntered() {}
|
||||
virtual void OnDragExited() {}
|
||||
virtual void OnDragEnded() {}
|
||||
|
||||
protected:
|
||||
virtual ~TrayIconObserver() {}
|
||||
|
|
Loading…
Reference in a new issue