Code covered by the BSD License  

Highlights from
Callback Stack

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 3.5 KB File ID: #21625

Callback Stack

by Sebastian Hölz

 

30 Sep 2008 (Updated 21 Jan 2009)

Easy way to add multiple callbacks to objects, which support callback-functions (e.g. HG objects)

| Watch this File

File Information
Description

Handy function to add/remove/append an arbitrary number of callbacks to an object (e.g. figure, axes, line, patch, surface, text, image, zoom, pan, rotate, ...).

This function is extremely useful, if you write general purpose functions, which should be executed as object-callbacks without deleting any already existing callback(s).

A simple example can illustrate the functionality. Click on the current axis after executing each command:

CallbackStack(gca,'ButtonDownFcn','disp(''Hello'')') % Now click
CallbackStack(gca,'ButtonDownFcn',{@disp, 'World'}) % Click again
CallbackStack(gca,'ButtonDownFcn',{@disp, 'Hello'}) % ...
CallbackStack(gca,'ButtonDownFcn',{@disp, 'Hello'})
CallbackStack(gca,'ButtonDownFcn',{@disp, 'World'},'add')
CallbackStack(gca,'ButtonDownFcn',{@disp, 'World'},'remove')

This should give you an idea of how to add/append/remove callbacks to an object. OK, hope you find this useful. For further details have a look in the help contained in the file.

Sebastian

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
21 Jan 2009

Revision 33:
- Better handling of different callback-styles (string, simple function handle, cell array).
- Removed some error-checking.
- New "add"-switch
- Bug-fixes.

Tag Activity for this File
Tag Applied By Date/Time
data exploration Sebastian Hölz 22 Oct 2008 10:22:13
multiple callbacks Sebastian Hölz 22 Oct 2008 10:22:13
graphics Sebastian Hölz 22 Oct 2008 10:22:13
multiple Sebastian Hölz 22 Oct 2008 10:22:13
graphical data Sebastian Hölz 22 Oct 2008 10:22:13

Contact us at files@mathworks.com