MATLAB: Respond to the left mouse click button in GUI

gui

Hi everyone,
I'm designing a GUI which having several editboxs (allow input), and a figure_axis(explanation figure corresponding to the clicked editbox). I want to it to display my assigned explanation figure when I click (left click) to editboxs. Is there any way to do this?
Thank you so much!

Best Answer

there is a problem with what you're trying to accomplish. here is a quick demo you can run. copy and paste into a mfile called clicktest. Here you can see the text field on the lower right updates the X and Y location of a mouse click but doesn't update when you click on a GUI interface (button, either edit boxes, and even the text field).
function clicktest()
fig = figure
hax = axes('Units','pixels');
surf(peaks)
uicontrol('Style', 'pushbutton', 'String', 'Clear',...
'Position', [20 20 50 20],...
'Callback', 'surf(randi(5,49,49)*peaks)');
% The pushbutton string callback
% calls a MATLAB function
ustring = uicontrol('Style','text',...
'Position',[400 45 120 20],...
'String','clicked objectt')
edit1= uicontrol('Style','edit',...
'Position',[400 95 120 20],...
'String','clicked object')
edit2= uicontrol('Style','edit',...
'Position',[400 115 120 20],...
'String','clicked object')
set(fig,'WindowButtonDownFcn',{@position,ustring});
end
function position(hobject,event,ustring)
C = get(hobject,'CurrentPoint');
set(ustring,'String',num2str(C));
end
I would go with a radio button group that you put next to each text box.