How to capture keyboard input in getrect
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!