Effacer les filtres
Effacer les filtres

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

4 vues (au cours des 30 derniers jours)
I don't know how to start with this.

Réponses (1)

Dinesh
Dinesh le 4 Jan 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":

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by