uifigure で作成したダイアログ​をモーダル化する方法​はありますか?

8 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2021 年 7 月 2 日
回答済み: MathWorks Support Team 2021 年 7 月 2 日
あるメインウィンドウの GUI の中で uifigure を実行してサブウィンドウとなる Figure を表示し、それをモーダル化したいのですが、方法があるか、教えてください。
メインウィンドウの GUI 内で dialog 関数や msgbox 関数でモーダルダイアログを作成し、表示させてみましたが、MATLABデスクトップに対しては、モーダル化されていますが、メインウィンドウの GUI をクリックすると、サブ GUI よりもメイン GUI が前に出てきてしまいます。

採用された回答

MathWorks Support Team
MathWorks Support Team 2021 年 7 月 2 日
MATLAB R2020b 以降のリリースでは、UIFigure (App Designer で作成した GUI) をモーダル化させるための WindowStyle プロパティがサポ―トされています。
f = uifigure;
f.Position = [500 500 370 270];
uibutton(f, 'Text','press', 'ButtonPushedFcn', @buttonPushed);
function buttonPushed(src,even)
f2 = uifigure;
f2.Position = [540 450 370 270];
f2.WindowStyle = 'modal'; % モーダル
end
R2020a 以前のバージョンをご利用の方は、R2020b 以降のバージョンへのアップグレードをぜひご検討ください。
もしくは、サブウィンドウに uifigure の代わりに inputdlg など、既にモーダルとなっているダイアログを使用する方法が考えられます。
f = uifigure;
f.Position = [500 500 370 270];
uibutton(f, 'Text','press', 'ButtonPushedFcn', @buttonPushed);
function buttonPushed(src,even)
prompt = {'Enter matrix size:','Enter colormap name:'};
dlg_title = 'Input';
num_lines = 1;
defaultans = {'20','hsv'};
answer = inputdlg(prompt,dlg_title,num_lines,defaultans);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeApp Designer を使用したアプリ開発 についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!