Main Content

images.stack.browser.CrosshairMovingEventData Class

Namespace: images.stack.browser

Event data passed when Crosshair ROI is moving

Since R2019b


The images.stack.browser.CrosshairMovingEventData class is the class passed to listeners when the crosshair in an orthosliceViewer object is moved interactively. The orthosliceViewer object triggers an event using the notify handle class method. MATLAB® assigns values to the properties of an images.stack.browser.CrosshairMovingEventData object and passes that object to the listener callback function (the event handler). Programmatic positioning of the crosshair does not trigger this event.

The images.stack.browser.CrosshairMovingEventData class is a handle class.


The notifyfunction creates an images.stack.browser.CrosshairMovingEventData object when called to trigger an event.


expand all

Event source, specified as a handle to the object that triggered the event.

Name of the event, specified as a character vector.

Position before the crosshair moved, specified as a three-element numeric vector of the form [x y z].

Position after crosshair moved, specified as a three-element numeric vector of the form [x y z].


collapse all

Load a stack of images.


Create a custom colormap for viewing slices.

cmap = parula(256);

View the image stack in the Orthoslice Viewer.

os = orthosliceViewer(vol,'Colormap',cmap);

Set up listeners for the two Orthoslice Viewer crosshair moving events. When you move the crosshair, the Orthoslice Viewer sends notifications of these events and executes the callback function you specify.


The allevents callback function displays the name of each event with the previous position and the current position of the crosshair.

function allevents(src,evt)
evname = evt.EventName;
            disp(['Crosshair moved previous position: ' mat2str(evt.PreviousPosition)]);
            disp(['Crosshair moved current position: ' mat2str(evt.CurrentPosition)]);
            disp(['Crosshair moving previous position: ' mat2str(evt.PreviousPosition)]);
            disp(['Crosshair moving current position: ' mat2str(evt.CurrentPosition)]);

Version History

Introduced in R2019b