Main Content

ダイアログ ボックスの更新

uialertuiconfirm などの関数を使用して、uifigure ベースのアプリにダイアログ ボックスを追加します。これらのダイアログ ボックスは、アプリで使用されるために特別に構成されています。errordlgquestdlg などの関数を使用したダイアログ ボックスの作成は、引き続きサポートされます。ただし、アプリの作成専用のダイアログ ボックスを使用することにはメリットがあります。これらのダイアログ ボックスには、以下のような追加のカスタマイズ オプションがあります。

  • カスタム アイコンを指定する機能

  • HTML または LaTeX のマークアップを使用してテキストを書式設定する機能

  • ダイアログ ボックスを閉じると実行される、コールバックを作成する機能

また、これらのダイアログ ボックスは、アプリを構成する UI Figure ウィンドウ内に表示されます。

Alert dialog box in a UI figure window. The app is visible behind the dialog box.

これらのメリットを活用するには、figure ベースのアプリを移行して関数 uifigure を使用する際に、アプリのダイアログ ボックスを作成するために呼び出す関数を更新します。次の表は、figure ベースのアプリでダイアログ ボックスの作成に使用できる関数と、それらに対応する、uifigure ベースのアプリ用に構成された関数を示しています。

figure ベースのアプリuifigure ベースのアプリ
関数関数
errordlg
errordlg("Operation unsuccessful","Error");

figure-based error dialog box

uialert
fig = uifigure;
uialert(fig,"Operation unsuccessful","Error")

uifigure-based error dialog box

warndlg
warndlg("This operation cannot be undone","Warning");

figure-based warning dialog box

uialert
fig = uifigure;
uialert(fig,"This operation cannot be undone","Warning", ...
    "Icon","warning")

uifigure-based warning dialog box

msgbox
msgbox("Operation completed","Done","modal");

figure-based message dialog box

uialert
fig = uifigure;
uialert(fig,"Operation completed","Done", ...
    "Icon","none")

uifigure-based message dialog box

helpdlg
helpdlg("Consider using a cell array","Data Types");

figure-based help dialog box

uialert
fig = uifigure;
uialert(fig,"Consider using a cell array","Data Types", ...
    "Icon","info")

uifigure-based help dialog box

questdlg
questdlg("Do you want to continue?","Confirm");

figure-based question dialog box

uiconfirm
fig = uifigure;
uiconfirm(fig,"Do you want to continue?","Confirm", ...
    "Options",["Yes" "No" "Cancel"])

uifigure-based question dialog box

waitbar
waitbar(0.3,"Loading...","Name","Please Wait");

figure-based progress dialog box

uiprogressdlg
fig = uifigure;
uiprogressdlg(fig,"Value",0.3, ...
    "Message","Loading...", ...
    "Title","Please Wait");

uifigure-based progress dialog box

関連するトピック