Nifty window close event

I want to handle an event when a window is closed. Does someone knoe how to do this?
Is it a xml tag like <interact onClick=“clicked()”> or something?

Is your closed button your own nifty button? Then yes, that’s the right tag, and you just put the method in the controller for your screen.

No, its not my own button. It’s the nifty button (the “x” button on top right corner of the window). I want to handle an event when the window is closed. A solution like a windowClosing listener or just an event on that nifty “x” button. Maybe I can get that button with a piece of code which loops through the built-in window elements of nifty.

There’s not a way to do that using xml but you can do that using eventbus and subscribing a screencontrol to WindowClosedEvent Here is the source code .

I now have the following code in my screen controller:

@NiftyEventSubscriber(id = "dialog-window")
public void onWindowClosed(final String id, final WindowClosedEvent event) {

    System.out.println("WINDOW CLOSED (dialog-window) ");

When i close the window (with id “dialog-window”) it seems that my event isn’t handled.
Nothing happens (except that the window just closes)
I took the code for the WindowClosedEvent class from your link