How to switch keyboard control from command window to GUI?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/503313/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/503313/image.png)
1 comentario
Rik
el 29 de En. de 2021
Editada: Rik
el 29 de En. de 2021
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.
Respuestas (0)
Ver también
Categorías
Más información sobre Desktop en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!