Event when notification is closed (using "x" button)

Answered

I'm periodically running a check which may create a balloon popup notification. I don't want for the thread to create a new notification if the old one is still visible so I store its visibility in a variable (setting it to true when calling the notify() method). Unfortunately the whenExpired()-Runnable is only called when the notification is expired by me. How can I find out if the notification was just closed (so I can set the visibility variable to false)?

0
2 comments

com.intellij.notification.NotificationsManager#getNotificationsOfType should work to check for existing, non-expired notifications.

1

You can also add a listener to the notification balloon:

notification.balloon?.addListener(object : JBPopupListener {
    override fun onClosed(event: LightweightWindowEvent) {
    
    }
})
0

Please sign in to leave a comment.