MATLAB Function Reference Previous page   Next Page
gcbo

Return handle of object whose callback is executing

Syntax

Description

h = gcbo returns the handle of the graphics object whose callback is executing.

[h, figure] = gcbo returns the handle of the current callback object and the handle of the figure containing this object.

Remarks

MATLAB stores the handle of the object whose callback is executing in the root CallbackObject property. If a callback interrupts another callback, MATLAB replaces the CallbackObject value with the handle of the object whose callback is interrupting. When that callback completes, MATLAB restores the handle of the object whose callback was interrupted.

The root CallbackObject property is read only, so its value is always valid at any time during callback execution. The root CurrentFigure property, and the figure CurrentAxes and CurrentObject properties (returned by gcf, gca, and gco, respectively) are user settable, so they can change during the execution of a callback, especially if that callback is interrupted by another callback. Therefore, those functions are not reliable indicators of which object's callback is executing.

When you write callback routines for the CreateFcn and DeleteFcn of any object and the figure ResizeFcn, you must use gcbo since those callbacks do not update the root's CurrentFigure property, or the figure's CurrentObject or CurrentAxes properties; they only update the root's CallbackObject property.

When no callbacks are executing, gcbo returns [] (an empty matrix).

See Also

gca, gcf, gco, rootobject

Finding and Identifying Graphics Objects for related functions


Previous page  gcbf gcd Next page

© 1994-2005 The MathWorks, Inc.