Emit a close event

This commit is contained in:
Samuel Attard 2017-05-29 21:33:43 +10:00
parent 9aa6b83f86
commit 6cdfb43e4e
5 changed files with 21 additions and 11 deletions

View file

@ -126,6 +126,10 @@ void Notification::OnShown() {
Emit("show"); Emit("show");
} }
void Notification::OnClosed() {
Emit("close");
}
void Notification::NotifyPropsUpdated() {} void Notification::NotifyPropsUpdated() {}
// Showing notifications // Showing notifications

View file

@ -35,6 +35,7 @@ class Notification : public mate::TrackableObject<Notification>,
void OnClicked() override; void OnClicked() override;
void OnReplied(std::string reply) override; void OnReplied(std::string reply) override;
void OnShown() override; void OnShown() override;
void OnClosed() override;
protected: protected:
Notification(v8::Isolate* isolate, Notification(v8::Isolate* isolate,

View file

@ -23,7 +23,9 @@ void AtomNotificationDelegateAdapter::NotificationClick() {
void AtomNotificationDelegateAdapter::NotificationReplied(std::string reply) { void AtomNotificationDelegateAdapter::NotificationReplied(std::string reply) {
observer_->OnReplied(reply); observer_->OnReplied(reply);
} }
void AtomNotificationDelegateAdapter::NotificationDestroyed() {} void AtomNotificationDelegateAdapter::NotificationDestroyed() {
observer_->OnClosed();
}
void AtomNotificationDelegateAdapter::NotificationFailed() {} void AtomNotificationDelegateAdapter::NotificationFailed() {}
} // namespace atom } // namespace atom

View file

@ -14,6 +14,7 @@ class NotifictionObserver {
virtual void OnClicked() {} virtual void OnClicked() {}
virtual void OnReplied(std::string reply) {} virtual void OnReplied(std::string reply) {}
virtual void OnShown() {} virtual void OnShown() {}
virtual void OnClosed() {}
protected: protected:
virtual ~NotifictionObserver() {} virtual ~NotifictionObserver() {}

View file

@ -37,16 +37,7 @@ Objects created with `new Notification` emit the following events:
**Note:** Some events are only available on specific operating systems and are **Note:** Some events are only available on specific operating systems and are
labeled as such. labeled as such.
#### Event: 'click' #### Event: 'show'
Returns:
* `event` Event
Emitted when the document changed its title, calling `event.preventDefault()`
will prevent the native window's title from changing.
#### Event: 'close'
Returns: Returns:
@ -64,6 +55,17 @@ Returns:
Emitted when the notification is clicked by the user. Emitted when the notification is clicked by the user.
#### Event: 'close'
Returns:
* `event` Event
Emitted when the notification is closed by manual intervention from the user.
This event is not guarunteed to be emitted in all cases where the notification
is closed.
#### Event: 'reply' _macOS_ #### Event: 'reply' _macOS_
Returns: Returns: