Miles - ok, when I push the button, I see a slightly different error
Error using interactive_move>dragger (line 80)
Not enough input arguments.
Look closely at the dragger function signature
function dragger(~,~,type)
It is expecting three input parameters. The first two are typically the source handle and some event data. But the third, in this case, appears to be a custom parameter which you need to define when you add dragger as the callback to the uipushtool
p = uipushtool(h,'CData',b,'TooltipString','Drag Plot',...
'Separator','on','ClickedCallback',@dragger);
Note how the other callbacks do this
set(gcf, 'windowbuttondownfcn', {@dragger,1});
set(gcf, 'windowbuttonmotionfcn', {@dragger,2});
set(gcf, 'windowbuttonupfcn', {@dragger,3});
set(gcf, 'keypressfcn', {@dragger,4});
So you need to pass in a "type" parameter.
But I don't know if this will fix your problem which is that you only want to drag plots when the button is clicked. I think that the callback for this tool should be something more like
function enableDragger(~,~)
if isempty(get(gcf, 'windowbuttondownfcn'))
set(gcf, 'windowbuttondownfcn', {@dragger,1});
set(gcf, 'windowbuttonmotionfcn', {@dragger,2});
set(gcf, 'windowbuttonupfcn', {@dragger,3});
set(gcf, 'keypressfcn', {@dragger,4});
else
set(gcf, 'windowbuttondownfcn', []);
set(gcf, 'windowbuttonmotionfcn', []);
set(gcf, 'windowbuttonupfcn', []);
set(gcf, 'keypressfcn', []);
end
So you add (or remove) the dragger function to (or from) the above callbacks. The only time that you can drag is when you've pressed the button (I'm assuming that the only code you have to add dragger as a callback to the four functions is through the enableDragger function) and that when you press the button again, you won't be able to drag.
Best Answer