gco

Returns the graphics object that was last clicked.

Category: Graphics > Graphics Objects

Syntax

obj = gco

Returns the current object of the current figure, or an empty object if none.

Description

The current object is the one under the mouse at the last click in the figure. It is stored in the CurrentObject property of the figure, and gco just reads it. Until something has been clicked, the result is empty.

Output arguments

obj
Handle of the current object, or an empty placeholder.

Example

Nothing clicked yet

figure
plot(1:3)
o = gco;
disp(class(o))
Output
matlab.graphics.GraphicsPlaceholder

See also

gcf gca gcbo get