How to switch keyboard control from command window to GUI?
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I am making a MATLAB GUI and would like for it to be largely keyboard-controlled, continuously recognizing if a key is being pressed and responding accordingly the wholt time the GUI is running. This is at the end of my GUI-generated script right now. op1(handles) is the call for the function where I execute other code. And I just created this generic KeyPress function (generated by right-clicking the GUI background in GUIDE). But when I run the main script, it does not seem to recognize this function to tell if a key is being pressed. It just types in the command window and does nothing in the GUI itself. It might be me putting stuff in the wrong order, or just misunderstanding what to do. Any insight would be appreciated.
1 个评论
Rik
2021-1-29
编辑:Rik
2021-1-29
I expect GUIDE has automagically set the KeyPressFcn to this function, in which case all keypresses should be captured (unless the cursos focus is in a text field).
Without the fig and m file it is often difficult to diagnose GUIDE issues, which is one of many reasons I dislike it for anything non-trivial. Please attach them to your question.
For general advice and examples for how to create a GUI (and avoid using GUIDE), have look at this thread.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!