Problems with UIFigureKeyPress and push buttons in App Designer

6 visualizaciones (últimos 30 días)
Georgy Kobunov
Georgy Kobunov el 18 de Oct. de 2020
Respondida: Satwik el 25 de Mzo. de 2025
Hi there! I noticed a very annoying thing
I am doing a calculator with abillity to enter operations and digits
When I click on any object (e.x. push button,text area), its borders get blue and then I am not able to use my keyboard. I need to click on free space in order to fix it.
Here is the example.
How can I deal with it?

Respuestas (1)

Satwik
Satwik el 25 de Mzo. de 2025
The issue you are experiencing is common in GUI applications, where the focus is shifted to a specific UI element after interaction, preventing keyboard input from being directed elsewhere. Here are two ways to address this issue:
1. Focus Management: Set Focus Back to Main Window: After a button click or any UI interaction, programmatically set the focus back to the main window or a specific element that should capture keyboard input.
% Assuming 'mainFigure' is your main GUI figure handle
uicontrol(mainFigure);
2. Event Listeners: Add event listeners to detect when a UI element is clicked and automatically redirect focus back to the desired element.
% Callback function for a button
function buttonCallback(~, ~)
% Your button logic here
uicontrol(mainFigure); % Redirect focus
end
I hope this helps!

Categorías

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

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by