Issue with Key Press Events in App Designer Plot

3 visualizzazioni (ultimi 30 giorni)
swapna kamatam
swapna kamatam il 27 Lug 2023
Risposto: Shubham il 8 Ott 2024
I encountered an issue while developing the App Designer application. The plot of detection points using the plot function is not capturing key press events when the plot is paused. I've tried various approaches, but the control is not passing to the key press callbacks.
If you have any insights or suggestions, please let me know

Risposte (1)

Shubham
Shubham il 8 Ott 2024
Hi Swapna,
In MATLAB App Designer, using "pause" can block key press events because it halts code execution and UI interaction. Here's how to address this issue:
  • Replace "pause()" with a loop that checks for key presses while updating the plot.
  • Use "drawnow" to process UI events and keep the interface responsive. Here's a simple implementation:
function plotWithKeyPressHandling(app)
% Plot some data
x = 1:10;
y = rand(1, 10);
plot(app.UIAxes, x, y, 'o');
% Responsive loop for key press handling
duration = 10; % Duration in seconds
startTime = tic; % Start timer
while toc(startTime) < duration
drawnow; % Process events, including key presses
end
end
  • Ensure "WindowKeyPressFcn" is set for the " UIFigure" to capture key events.
Kindly refer to the following documentation links for more information:
Hope this helps!

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by