MATLAB Functions Help Desk

gcbo

Purpose

Return the handle of the object whose callback is currently executing

Syntax

h = gcbo

[h, figure] = gcbo

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's 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 inter rupted by another callback. Therefore, those functions are not reliable indicators of which object's callback is executing.

gcbo must be used in conjunction with CreateFcn and DeleteFcn callbacks, and with the Figure ResizeFcn callback, since those callbacks do not update the Root's CurrentFigure property, or the Figure's CurrentObject or CurrentAxis properties, but only update the Root's CallbackObject property.

When no callbacks are executing, gcbo returns [].

See Also

gca, gcf, gco, root



[ Previous | Help Desk | Next ]