0
votes

I built a GUI using GUIDE, it is pretty simple, it has two axes an edit text and a push button

I want that, when clicking the mouse over axes_1, I get the position and update the edit text with the X position.

In the opening function I put the following

set(handles.axes_1, 'ButtonDownFcn', @axes_1_ButtonDownFcn);

and in axes_1_ButtonDownFcn i put

pos=get(hObject,'CurrentPoint');
disp(['You clicked X:',num2str(pos(1)),', Y:',num2str(pos(2))])
handles.value= pos(1);
set(handles.edit1,'String',handles.value);

but is giving me the following error

Reference to non-existent field 'edit1'. Error in trytool>axes_1_ButtonDownFcn (line 198) set(handles.edit1,'String',handles.value);

Error while evaluating axes ButtonDownFcn

edit1 is the tag name of the edit text, is not a typo or anything like that, why is the function not recognizing the edit text?

Thank you so much!

1
Can you debug and display what is actually contained in the handles structure. That might give you a hint.Justin

1 Answers

1
votes

I tried to build a GUI with your code, and it works well if you comment the code you added to the opening function:

%set(handles.axes_1, 'ButtonDownFcn', @axes_1_ButtonDownFcn);