Matlab GUI keypress function changes after a button press function is executed!!!
Ältere Kommentare anzeigen
Hi,
I am having an issue with GUI keypress function. I have a GUI made via Guide. I also created a keypress function for the GUI to detect right and left arrow keys. It works fine when I run the GUI code and try pressing any keys.
However, the next thing I do in the GUI is to press a button to load a file and do some math with the data and eventually plot two graphs. After the graphs show up, somehow the keypress function does not work anymore. When I try to press any key the command window is active and I type there. The GUI window does not detect any keypress anymore.
Why does the keypress functionality change after I load the data? Do I have to add anything specific at the end of the button press function?
Please advice me.
Sujay.
Antworten (1)
Walter Roberson
am 13 Mär. 2017
0 Stimmen
The "plot two graphs" part might be responsible. The default cla() that is done when you plot without "hold off" clears the axes callbacks as well.
Sometimes the easiest approach is just to add the callback back in after you finish plotting.
2 Kommentare
sujay Ray
am 13 Mär. 2017
Walter Roberson
am 13 Mär. 2017
ax = gca;
KPF = get(ax, 'KeyPressFcn');
... do the plotting
set(ax, 'KeyPressFcn', KPF);
Kategorien
Mehr zu Environment and Settings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!