Filter löschen
Filter löschen

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

4 Ansichten (letzte 30 Tage)
I don't know how to start with this.

Antworten (1)

Dinesh
Dinesh am 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":

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by