MATLAB: Programmatically select a specific object when switching on plotedit

currentaxescurrentobjectploteditselection

Is there any way to select an object when issuing the command
plotedit(hfig,'on');
I tried to overwrite 'CurrentObject' property but it did not work. There is also a 'CurrentAxes' property, and that did not work either.
Is there any solution?

Best Answer

OK. Sorry folks, I have found it.
In the defining function:
f=figure;
object=uicontrol(.........,'ButtonDownFcn',{@ButtonDownFcn_Callback,f},'NextPlot','replacechildren',....)
% do it for all objects you define (or you want to select this way)
NextPlot property is necessary only for axes.
and the callback function should do:
function ButtonDownFcn_Callback(hObject,eventdata,hfig)
% hfig=figure; handle to figure containing the objects
% find all axes objects
hhh=findobj(hfig,'Type','axes');
%unselect all objects
[NN,~]=size(hhh);
for i=1:NN
hhh(i).Selected='off';
end
% select the currentobject
hfig.CurrentObject.Selected='on';
plotedit on;
% the object you clicked on will only be selected.
end
and voila, it works.
Note, that plotedit should be switched off in order to use callback again!