How to switch keyboard control from command window to GUI?

3 ビュー (過去 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 Center および File ExchangeDesktop についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by