How to use windowkeypressfcn

조회 수: 16 (최근 30일)
Brenda FOCHIVÉ
Brenda FOCHIVÉ 2019년 5월 9일
댓글: Brenda FOCHIVÉ 2019년 5월 10일
I have written a 5code that draws a graph. I want that each time the user clicks on escape the graph comes back to its original state. This is my code:
Figure('windowkeypressfcn',@keyP)
Function keyP(source, event)
KeyPressed=eventData.key;
If strcmp(KeyPressed,'escape')
View (3)
end
end
When I run it shows errors. It says The class "eventdata" is undefined. Perhaps java is not running

답변 (1개)

Kevin Phung
Kevin Phung 2019년 5월 9일
편집: Kevin Phung 2019년 5월 9일
function keyP(source, event)
KeyPressed=event.Key;
if strcmp(KeyPressed,'escape')
view(3)
end
end
It's as the error says. You never defined a variable eventData. Your input is 'event'
  댓글 수: 1
Brenda FOCHIVÉ
Brenda FOCHIVÉ 2019년 5월 10일
I have edited it but when I click on escape key the function do not run. I instead see the command window pop up. It's like the figure do not have the focus again.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by