필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
I don't know how to start with this.

답변 (1개)

Dinesh
Dinesh 2024년 1월 4일
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":

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by