Matlab GUI keypress function changes after a button press function is executed!!!
显示 更早的评论
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.
回答(1 个)
Walter Roberson
2017-3-13
0 个投票
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 个评论
sujay Ray
2017-3-13
Walter Roberson
2017-3-13
ax = gca;
KPF = get(ax, 'KeyPressFcn');
... do the plotting
set(ax, 'KeyPressFcn', KPF);
类别
在 帮助中心 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!