Fragment for Close Button

Hi,
Jmix 1.5…
In several screens I want to use a fragment, that handles a simple close button. Just that “x” in then corner…

Description has the buttonX control,
controller just that handler below.

@Subscribe(“btnX”)
public void onBtnXClick(final Button.ClickEvent event) {
close(StandardOutcome.CLOSE);
}

As simple. But doesn’t work.
Subscribe wasn’t allowed in that context.

How can I close the screen, with this nested fragment that holds the close button?
Thanks in advance,
br
HP

Hi,

Try something like this:

    @Subscribe("closeBtn")
    public void onCloseBtnClick(final Button.ClickEvent event) {
        FrameOwner hostController = getHostController();
        if (hostController instanceof Screen) {
            Screen screen = (Screen) hostController;
            screen.close(StandardOutcome.CLOSE);
        }
    }