Skip to content

Interactive Command do not trigger cancel method when the user closes the window #379

@NicoKiaru

Description

@NicoKiaru

As descirbed in the title, it would be nice to have access to a method which is called when the user closes the window of an interactive command ( InteractiveCommand)

This minimal command example shows that the cancel method is never called:

import net.imagej.ImageJ;
import org.scijava.command.Command;
import org.scijava.command.InteractiveCommand;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

@Plugin(type = Command.class, menuPath = "Dummy")
public class DummyInteractiveCommand extends InteractiveCommand {

    @Parameter(min = "0", max = "255", style = "slider")
    double dummySlider;

    public void run() {
        System.out.println("Run called");
    }

    @Override
    public void cancel() {
        // Actually never called
        System.out.println("Cancel called");
    }
    

    public static void main(String... args) {
        final ImageJ ij = new ImageJ();
        ij.ui().showUI();
        // Launching dummy command
        ij.command().run(DummyInteractiveCommand.class,true);
    }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions