Main Content

images.ui.graphics.events.ObjectInfoEventData Class

R2026b

Namespace: images.ui.graphics.events
Superclasses: event.EventData

Event data is passed when an object in the viewer is interactively clicked

Since R2026b

Description

The images.ui.graphics.events.ObjectInfoEventData class is the class passed to listeners when an object in a Viewer is interactively clicked. When the object triggers an event using the notify handle class method, MATLAB® assigns values to the properties of an ObjectInfoEventData object and passes that object to the listener callback function (the event handler).

In the callback function, use the Object property to determine what was clicked, the ClickType property to distinguish click types, and the Position property to use the click location.

The images.ui.graphics.events.ObjectInfoEventData class is a handle class.

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

The notify handle class method creates an ObjectInfoEventData object when called to trigger an event.

Properties

expand all

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

Attributes:

GetAccess
public
SetAccess
private

Name of the event, specified as a character vector.

Attributes:

GetAccess
public
SetAccess
private

Data Types: char

Handle to the clicked element in the viewer (such as a Volume or Surface object). Returns an empty array [] if the click occurs on empty space.

Attributes:

GetAccess
public
SetAccess
private

Type of mouse click, specified as 'left', 'right', 'double', 'middle', 'ctrl-left', 'shift-left', or 'alt-left'.

Attributes:

GetAccess
public
SetAccess
private

Data Types: char

Click location in 3-D world coordinates, returned as a 1-by-3 vector of the form [x y z]. For volumes with transparent rendering, the accuracy of this location might be limited.

Attributes:

GetAccess
public
SetAccess
private

Data Types: double

Examples

collapse all

Use object click event data to run different callback code depending on the clicked object, click type, and click location.

function myCallbk(~, evtData)
   clickedObj = evtData.Object;
   clickType = evtData.ClickType;
   clickPos = evtData.Position;

   if isempty(clickedObj)
       fprintf('Clicked empty space at [%.1f, %.1f, %.1f].\n', ...
           clickPos(1), clickPos(2), clickPos(3));
       return
   end

   switch clickType
       case 'double'
           fprintf('Double-clicked %s at [%.1f, %.1f, %.1f].\n', ...
               class(clickedObj), clickPos(1), clickPos(2), clickPos(3));
       case 'right'
           fprintf('Right-clicked %s.\n', class(clickedObj));
       otherwise
           fprintf('Clicked %s at [%.1f, %.1f, %.1f].\n', ...
               class(clickedObj), clickPos(1), clickPos(2), clickPos(3));
   end
end

Version History

Introduced in R2026b