Hello, all I wrote small GUI demo which has a "LoadImage" button, and in the LoadImageBtn_Callback call the LoadImage function to load image, getrect, then do some image processing and it works fine.
function LoadImageBtn_Callback(hObject, eventdata, handles)
LoadImage(hObject, eventdata, handles);
function LoadImage(hObject, eventdata, handles)
I = imread('cameraman.tif');
imshow(I);
rct = getrect;
Now I want to add keyboard shortcut, and I add a WindowKeyPressFcn function of the figure, in which call LoadImage function.
function figure1_WindowKeyPressFcn(hObject, eventdata, handles)
switch eventdata.Key
case 'l'
LoadImage(hObject, eventdata, handles);
end
Now the problem is: when I click the "LoadImage" button and in the processing of getrect, if I click keyboard, all the keyboard event is missing(which is desired). But when I click the "L" shortcut to call the LoadImage function, if I click keyboard in the processing of getrect, it will appear in the matlab command window which is very annoying because I have to switch back to the GUI window. So I wonder what's the difference? And how to capture such keyboard input in the processing of getrect?
I have added breakpoint in the function figure1_WindowKeyPressFcn, but it seems that in the processing of getrect the function figure1_WindowKeyPressFcn is never called.