Appdesigner uigetfile focus error

2 Ansichten (letzte 30 Tage)
한섭
한섭 am 3 Apr. 2024
Beantwortet: Jorg Woehl am 14 Mai 2024
function DPlotButtonPushed(app, event)
if app.LoadButton == event.Source
[filenames2labels, FilePathState] = uigetfile({'*.txt'; '*.mat'; '*.m'; '*.mlx'; '*.csv'}, '파일 선택', 'MultiSelect','on');
if isequal(filenames2labels, 0)
disp('파일 선택이 취소되었습니다');
return;
else
fullpath = fullfile(FilePathState, filenames2labels);
disp(['선택한 파일 : ', filenames2labels]);
disp(['전체 경로 : ', FilePathState]);
return;
end
elseif app.AboutButton == event.Source
web('https://www.mathworks.com/help/matlab/', '-browser');
elseif app.ExitButton == event.Source
delete(app);
elseif app.SaveButton == event.Source
axesHandle = app.UIAxes;
% Capture the plot as an image
frame = getframe(axesHandle);
img = frame.cdata;
% Open a dialog to select the file path to save the image
[filename, pathname] = uiputfile({'*.png';'*.jpg';'*.bmp';'*.tif'}, 'Save As');
% Check if the user canceled the operation
if isequal(filename,0) || isequal(pathname,0)
disp('User selected Cancel');
return;
else
% Construct the full file path
fullFilePath = fullfile(pathname, filename);
% Save the captured plot as an image file
imwrite(img, fullFilePath);
disp(['Image saved as: ' fullFilePath]);
return;
end
end
end
end
appdesigner에서 버튼을 누르면 파일 선택 창이 나오도록 uigetfile 함수로 gui를 구축하고 있습니다. 구축하는 과정 중 파일 선택 창에서 취소 버튼을 누르면 focus가 이상해져서 파일 선택기 취소 후 app 유지 상태가 아니라 , 파일 선택기에서 취소를 누르면 app 자체가 최소화 되는 문제가 발생하고 있습니다.
code 작성은 위와 같이 했는데 해결 방법이 뭔가요 ??? 잘 모르겠습니다 ㅜㅜ
  2 Kommentare
Angelo Yeo
Angelo Yeo am 3 Apr. 2024
mlapp 파일을 공유해주시고 정확한 재현 과정을 서술해주시면 도움 받기에 더 효과적일 것으로 생각합니다.
한섭
한섭 am 7 Apr. 2024
Bearbeitet: 한섭 am 7 Apr. 2024
이 파일인데 왼쪽 위의 load 버튼으로 파일 선택 창을 연 후에 파일 선택 창에서 취소 버튼을 누르면, 파일 선택 창만 없어지는게 아니라 app이 아예 최소화 되는 현상이 발생합니다. 이 현상을 해결하고 싶어요

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Kevin Holly
Kevin Holly am 8 Apr. 2024
첨부된 앱을 참조하세요.
focus(app.UIFigure)

Weitere Antworten (1)

Jorg Woehl
Jorg Woehl am 14 Mai 2024
I am not sure if this answers your question but judging from the title and your code it may...: check out my File Exchange contribution https://www.mathworks.com/matlabcentral/fileexchange/165961-fixfocus.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by