I am showing lot of buttons on image using pushbutton with UIcontrol.(around 20)
How to handle callback with single function(which has similar behaviour and i just have to change id for each button,i dont want to write 20 callback for each.)
S = uicontrol('style','push',...
'units','pix',...
'position',Pos,...
'string',Button_name,...
'fontsize',10,...
'fontweight','bold');
set(S,'callback',{@pb1_call}) % Set the callbacks.
end
function [] = pb1_call(varargin)
disp(varargin)
end
The Matlab documentation describes this reasonably well, look at uicontrol properties.
The callback fires with the firing object and event data. If you set a Tag onto the uicontrol you could do:
Also worth noting, if the callback is a method of a handle class then there are three arguments: