ListenToEvents tutorial :: MsEvent & WinEvent

Hi all,

I am running the ListenToEvents tutorial and I have a question in regards to MsEvent and WinEvent. These events are not being logged but the DatasetCreatedEvent and DisplayActivatedEvent are logged when the dataset is created and displayed.

I would have thought that by resizing the image window, zooming in/out and panning that these actions would have triggered either the MsEvent and/or WinEvent.

I have also added another method to the MyEventSubscriber class in the tutorial to log a DatasetDeletedEvent to ensure that the MyEventSubscriber object did not fall out of scope after the dataset was created and displayed.

	/** Responds to dataset deletion events. */
	@EventHandler
	public void onEvent(final DatasetDeletedEvent evt) {
		logEvent(evt);
	}

I ran the tutorial, played around with the image (zoom, resize, pan) and then closed the image window. Here’s the log output:

[INFO] [DatasetCreatedEvent] 
	context = org.scijava.Context@131f139b
	consumed = false
	object = Events Demo
[INFO] [DisplayActivatedEvent] 
	context = org.scijava.Context@131f139b
	consumed = false
	display = plugin:class net.imagej.display.DefaultImageDisplay: type=interface net.imagej.display.DataView, name=Events Demo, objects={net.imagej.display.DefaultDatasetView@2482c23d}
[INFO] [DatasetDeletedEvent] 
	context = org.scijava.Context@131f139b
	consumed = false
	object = Events Demo

Am I misunderstanding the use of, or concept behind, MsEvent and WinEvent?

Thanks for your time and for any advice.

– Joe

1 Like

Nope, your understanding is correct. The current behavior is erroneous.

The problem is that the legacy user interface (part of the imagej-legacy component)—which provides backwards compatibility with ImageJ1—is not fully hooked up to the SciJava event framework. That is: that UI does not listen for AWT events and forward them on to the SciJava event framework.

If you use the Swing UI, then the events are reported as expected.

I filed imagej/imagej-legacy#132 to track this bug, which I hope to fix later this week.