How to capture keyboard input in getrect
显示 更早的评论
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;
%do image processing...
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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Desktop 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!