I want a button to be pressed in MATLAB GUI when Enter key is pressed. How to do it?
28 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I have a pushbutton added in my MATLAB GUI and I want it to be pressed whenever Enter key is pressed. How can I do that?
0 Commenti
Risposte (2)
Nathan Greco
il 7 Lug 2011
I do something similar to this. Use keypress functions, and check to see if the current character being pressed is the enter key (carriage return).
Assuming your main GUI figure is named figure1, write this in each keypress function in your GUI:
currChar = get(handles.figure1,'CurrentCharacter');
if isequal(currChar,char(13)) %char(13) == enter key
%call the pushbutton callback
end
Note that doing this will not let you type the enter key within your edit text, since any instance of the enter key will call the push button.
1 Commento
Arno Patrice
il 14 Gen 2013
you have to add it to keypress of every active uicontrol (edit box for example) where you want it to act.
Doug Hull
il 7 Lug 2011
I doubt you can in any reasonable way.
You need to be more specific about "whenever the enter key is pressed", but I don't think you can do this.
A better question is "Why do you want to?" Please modify your question to answer this, DO NOT ADD IT as an answer to this question.
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!