MATLAB Answers

Appdesigner: KeyPressFcn in a while loop

21 views (last 30 days)
MSP
MSP on 29 May 2019
Edited: MSP on 29 May 2019
Hi,
I recently saw that matworks implement KeyPressfcn in the app designer. I was trying to explore a bit and do a keystroke recognition program but unfortunately I tried something that I could not solve. First I just added a callback to KeyPressFcn. The idea is to hit any button and assign it to the base workspace.
function UIFigureKeyPress(app, event)
app.key = event.Key;
assignin('base','key1', app.key)
end
Extending the program, I tried to put this recognition inside the loop, so the recognition only occurs when the button is pushed.
function StartStopButtonValueChanged(app, event)
app.button = app.StartStopButton.Value;
while app.button == 1
assignin('base','key2', app.key)
pause(0.0001)
end
end
since the program gets stuck in the loop, I can not use the other function. Question is: how can I open the other function in parallel or call the other function inside the loop?
I've tried a lot of thins and even lost the north and the creativity trying to make it work. Could someone help me by giving me the light on how should I call the loop or how can I make the recognition work only when the button pushed?
I'm already grateful,
Sincerely
Martin

Answers (0)

Community Treasure Hunt

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

Start Hunting!