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!