0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JUCE Tips

Last updated at Posted at 2025-01-05

極めて個人的なJUCEのTips。

Yes/Noのダイアログ (非同期)

これを書いてる今の時代、ダイアログボックスは基本的に非同期で扱うべきものらしい。

sample.cpp
void showYesNoDialog()
{
    // ダイアログオプションを設定
    auto options = juce::MessageBoxOptions()
        .withIconType (juce::MessageBoxIconType::QuestionIcon)
        .withTitle ("Confirmation")
        .withMessage ("Do you want to delete this item?")
        .withButton ("Yes")
        .withButton ("No");

    // 非同期でダイアログを表示
    juce::AlertWindow::showAsync(options, [this, rowNumber](int result) {
        if (result == 1) // "Yes" ボタンがクリックされた場合
        {
            processor->deleteServerPatchData(rowNumber);
        }
        else
        {
            //  "No"の場合の処理
        }
    });
}

Yes/No/Cancelの場合は下記。

sample.cpp
void showYesNoCancelDialog()
{
    // ダイアログオプションを設定
    auto options = juce::MessageBoxOptions()
        .withIconType (juce::MessageBoxIconType::QuestionIcon)
        .withTitle ("Confirmation")
        .withMessage ("Do you want to delete this item?")
        .withButton ("Yes")
        .withButton ("No")
        .withButton ("Cancel");

    // 非同期でダイアログを表示
    juce::AlertWindow::showAsync(options, [this, rowNumber](int result) {
        if (result == 1) // "Yes" ボタンがクリックされた場合
        {
            processor->deleteServerPatchData(rowNumber);
        }
        else if (result == 2)
        {
            //  "No"の場合の処理
        }
        else if (result == 0)
        {
            //  "Cancel"の場合の処理
        }
    });
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?