문제

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!

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top