How to switch keyboard control from command window to GUI?

조회 수: 6 (최근 30일)
Natalie Link
Natalie Link 2021년 1월 29일
편집: Rik 2021년 1월 29일
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
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개)

카테고리

Help CenterFile Exchange에서 Desktop에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by