Issue with Key Press Events in App Designer Plot

3 vues (au cours des 30 derniers jours)
swapna kamatam
swapna kamatam le 27 Juil 2023
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

Réponses (1)

Shubham
Shubham le 8 Oct 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!

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by