Borrar filtros
Borrar filtros

Can I navigate between Edit Fields using keyboard arrow keys in MATLAB App Designer after running the app? Does anyone know the codes.?

4 visualizaciones (últimos 30 días)
I don't know how to start with this.

Respuestas (1)

Dinesh
Dinesh el 4 de En. de 2024
Hi Subathra,
MATLAB App Designer does not support keyboard navigation between Edit Fields by default. However, you can create custom key press callbacks to enable this. Assign a 'KeyPressFcn' to the UIFigure and use 'focus' within the callback to set the focus to the desired field based on the key pressed.
The following is an example for right arrow navigation:
app.UIFigure.KeyPressFcn = @(src, event) switchKey(event);
function switchKey(event, app)
if strcmp(event.Key, "rightarrow")
editFields = {app.EditField1, app.EditField2, app.EditField3}; % List of all edit fields in order
currentField = app.UIFigure.CurrentObject; % Get the active field
currentIndex = find(editFields == currentField);
nextIndex = mod(currentIndex, numel(editFields)) + 1; % Get the index of the next edit field
focus(editFields{nextIndex}); % Set focus to the next edit field
end
end
Similarly, you can implement for other arrow keys.
The following link is the documentation for the "KeyPressFcn" callback of "uifigure":
The following link is the documentation of "focus":

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by