How to use windowkeypressfcn

6 vues (au cours des 30 derniers jours)
Brenda FOCHIVÉ
Brenda FOCHIVÉ le 9 Mai 2019
Commenté : Brenda FOCHIVÉ le 10 Mai 2019
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

Réponses (1)

Kevin Phung
Kevin Phung le 9 Mai 2019
Modifié(e) : Kevin Phung le 9 Mai 2019
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 commentaire
Brenda FOCHIVÉ
Brenda FOCHIVÉ le 10 Mai 2019
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by