Issue with Key Press Events in App Designer Plot

3 visualizaciones (últimos 30 días)
swapna kamatam
swapna kamatam el 27 de Jul. de 2023
Respondida: Shubham el 8 de Oct. de 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

Respuestas (1)

Shubham
Shubham el 8 de Oct. de 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!

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by