close all;

function cb_tag (hax, ~)
  fprintf (2, 'cb_tag: callback executed\n');
%  fflush (2);
endfunction

function cb_userdata (hax, ~)
  fprintf (2, 'cb_userdata: callback started\n');
%  fflush (2);
  set (hax, 'tag', 'foo');
  fprintf (2, 'cb_userdata: called set() once\n');
%  fflush (2);
  set (hax, 'tag', 'bar');
  fprintf (2, 'cb_userdata: called set() twice\n');
%  fflush (2);
  set (hax, 'tag', '');
  fprintf (2, 'cb_userdata: called set() thrice\n');
%  fflush (2);
endfunction

hf = figure ();
hax = gca ();
set (hax, 'interruptible', 'off');
addlistener (hax, 'tag', @cb_tag);
addlistener (hax, 'userdata', @cb_userdata);

set (hax, 'busyaction', 'queue');

fprintf (2, ['\n' '"busyaction" = "queue"' '\n']);
fprintf (2, ['changing "userdata"' '\n']);
set (hax, 'userdata', 5);

set (hax, 'busyaction', 'cancel');

fprintf (2, ['\n' '"busyaction" = "cancel"' '\n']);
fprintf (2, ['changing "userdata"' '\n']);
set (hax, 'userdata', 0);

