I want to create a GUI, in which i plot a histogram into an axes. For this axes, I want a button down function to react in certain ways, depending on what bin of the histogram I am clicking at. I created the GUI with guide containing the axes 'handles.histo' and, through guide, made the histo_ButtonDownFcn(hObject, eventdata, handles) appear in the code.
function histo_ButtonDownFcn(hObject, eventdata, handles)
If i click on the axes itself, it works perfectly. But due to the problems that occur when it comes to adding the histogram, i need to additionally set histo_ButtonDownFcn as a ButtonDownFcn for the histogram h in the code.
axes(handles.histo);
h=imshow(myHistogram);
set(h,'ButtonDownFcn',@histo_ButtonDownFcn);
but for some reason, after adding this line, I don't have access to any handle anymore in the ButtonDownFcn, so if I would for instance like to change the string of some text field handles.text1 within the ButtonDownFcn
set(handles.text1,'String','newstring');
it would tell me:
Error using GUI_versuch_5>histo_ButtonDownFcn (line 108)
Not enough input arguments.
Error while evaluating image ButtonDownFcn
So it seems as if the input data (hObject, eventdata, handles) is not passed to the ButtonDownFcn anymore...
I would be grateful for any help or suggestions about how to solve this problem!