mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Add MessageBoxOptions class for specifying a set of AlertWindow and NativeMessageBox options
- Add AlertWindow::show() and showAsync() methods that take a MessageBoxOptions argument - Add NativeMessageBox::show() and showAsync() methods that take a MessageBoxOptions argument - Update the DialogsDemo to demonstrate the new methods - Deprecate AlertWindow::showNativeDialogBox() in favour of the NativeMessageBox methods - Pass button strings specified in MesssageBoxOptions to native dialog boxes correctly - Use modern TaskDialog on Windows for the native dialog box where available
This commit is contained in:
parent
89ca17cf34
commit
551d7b9c5b
54 changed files with 1357 additions and 595 deletions
|
|
@ -193,7 +193,7 @@ private:
|
|||
addAndMakeVisible (textButton);
|
||||
|
||||
shapeButton.setShape (getJUCELogoPath(), false, true, false);
|
||||
shapeButton.onClick = [] { AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, "Alert", "This is an AlertWindow"); };
|
||||
shapeButton.onClick = [] { AlertWindow::showMessageBoxAsync (MessageBoxIconType::InfoIcon, "Alert", "This is an AlertWindow"); };
|
||||
addAndMakeVisible (shapeButton);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ private:
|
|||
}
|
||||
else
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Camera open failed",
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon, "Camera open failed",
|
||||
"Camera open failed, reason: " + error);
|
||||
}
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ private:
|
|||
|
||||
void errorOccurred (const String& error)
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::InfoIcon,
|
||||
"Camera Device Error",
|
||||
"An error has occurred: " + error + " Camera will be closed.");
|
||||
|
||||
|
|
@ -378,7 +378,7 @@ private:
|
|||
|
||||
void sharingFinished (bool success, bool isCapture)
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::InfoIcon,
|
||||
isCapture ? "Image sharing result" : "Video sharing result",
|
||||
success ? "Success!" : "Failed!");
|
||||
|
||||
|
|
|
|||
|
|
@ -89,19 +89,14 @@ public:
|
|||
// This method gets called on the message thread once our thread has finished..
|
||||
void threadComplete (bool userPressedCancel) override
|
||||
{
|
||||
if (userPressedCancel)
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
|
||||
"Progress window",
|
||||
"You pressed cancel!");
|
||||
}
|
||||
else
|
||||
{
|
||||
// thread finished normally..
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
|
||||
"Progress window",
|
||||
"Thread finished ok!");
|
||||
}
|
||||
const String messageString (userPressedCancel ? "You pressed cancel!" : "Thread finished ok!");
|
||||
|
||||
AlertWindow::showAsync (MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Progress window")
|
||||
.withMessage (messageString)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
|
||||
// ..and clean up by deleting our thread object..
|
||||
delete this;
|
||||
|
|
@ -177,12 +172,13 @@ public:
|
|||
[] (bool granted)
|
||||
{
|
||||
if (! granted)
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
|
||||
"Permissions warning",
|
||||
"External storage access permission not granted, some files"
|
||||
" may be inaccessible.");
|
||||
}
|
||||
AlertWindow::showAsync (MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::WarningIcon)
|
||||
.withTitle ("Permissions warning")
|
||||
.withMessage ("External storage access permission not granted, some files"
|
||||
" may be inaccessible.")
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -222,9 +218,12 @@ private:
|
|||
{
|
||||
void operator() (int result) const noexcept
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
|
||||
"Alert Box",
|
||||
"Result code: " + String (result));
|
||||
AlertWindow::showAsync (MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Alert Box")
|
||||
.withMessage ("Result code: " + String (result))
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -246,10 +245,14 @@ private:
|
|||
auto optionIndexChosen = aw.getComboBoxComponent ("option")->getSelectedItemIndex();
|
||||
auto text = aw.getTextEditorContents ("text");
|
||||
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, "Alert Box",
|
||||
"Result code: " + String (result) + newLine
|
||||
+ "Option index chosen: " + String (optionIndexChosen) + newLine
|
||||
+ "Text: " + text);
|
||||
AlertWindow::showAsync (MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Alert Box")
|
||||
.withMessage ("Result code: " + String (result) + newLine
|
||||
+ "Option index chosen: " + String (optionIndexChosen) + newLine
|
||||
+ "Text: " + text)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
DialogsDemo& demo;
|
||||
|
|
@ -259,11 +262,11 @@ private:
|
|||
{
|
||||
if (type >= plainAlertWindow && type <= questionAlertWindow)
|
||||
{
|
||||
AlertWindow::AlertIconType icon = AlertWindow::NoIcon;
|
||||
MessageBoxIconType icon = MessageBoxIconType::NoIcon;
|
||||
|
||||
if (type == warningAlertWindow) icon = AlertWindow::WarningIcon;
|
||||
if (type == infoAlertWindow) icon = AlertWindow::InfoIcon;
|
||||
if (type == questionAlertWindow) icon = AlertWindow::QuestionIcon;
|
||||
if (type == warningAlertWindow) icon = MessageBoxIconType::WarningIcon;
|
||||
if (type == infoAlertWindow) icon = MessageBoxIconType::InfoIcon;
|
||||
if (type == questionAlertWindow) icon = MessageBoxIconType::QuestionIcon;
|
||||
|
||||
AlertWindow::showMessageBoxAsync (icon, "This is an AlertWindow",
|
||||
"And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.",
|
||||
|
|
@ -271,7 +274,7 @@ private:
|
|||
}
|
||||
else if (type == okCancelAlertWindow)
|
||||
{
|
||||
AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon, "This is an ok/cancel AlertWindow",
|
||||
AlertWindow::showOkCancelBox (MessageBoxIconType::QuestionIcon, "This is an ok/cancel AlertWindow",
|
||||
"And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.",
|
||||
{}, {}, {},
|
||||
ModalCallbackFunction::create (AlertBoxResultChosen{}));
|
||||
|
|
@ -291,7 +294,7 @@ private:
|
|||
{
|
||||
asyncAlertWindow = std::make_unique<AlertWindow> ("AlertWindow demo..",
|
||||
"This AlertWindow has a couple of extra components added to show how to add drop-down lists and text entry boxes.",
|
||||
AlertWindow::QuestionIcon);
|
||||
MessageBoxIconType::QuestionIcon);
|
||||
|
||||
asyncAlertWindow->addTextEditor ("text", "enter some text here", "text field:");
|
||||
asyncAlertWindow->addComboBox ("option", { "option 1", "option 2", "option 3", "option 4" }, "some options");
|
||||
|
|
@ -326,9 +329,12 @@ private:
|
|||
chosen << (result.isLocalFile() ? result.getLocalFile().getFullPathName()
|
||||
: result.toString (false)) << "\n";
|
||||
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
|
||||
"File Chooser...",
|
||||
"You picked: " + chosen);
|
||||
AlertWindow::showAsync (MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("File Chooser...")
|
||||
.withMessage ("You picked: " + chosen)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
});
|
||||
}
|
||||
else if (type == loadWithPreviewChooser)
|
||||
|
|
@ -349,9 +355,12 @@ private:
|
|||
chosen << (result.isLocalFile() ? result.getLocalFile().getFullPathName()
|
||||
: result.toString (false)) << "\n";
|
||||
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
|
||||
"File Chooser...",
|
||||
"You picked: " + chosen);
|
||||
AlertWindow::showAsync (MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("File Chooser...")
|
||||
.withMessage ("You picked: " + chosen)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
},
|
||||
&imagePreview);
|
||||
}
|
||||
|
|
@ -401,9 +410,12 @@ private:
|
|||
}
|
||||
#endif
|
||||
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
|
||||
"File Chooser...",
|
||||
"You picked: " + name);
|
||||
AlertWindow::showAsync (MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("File Chooser...")
|
||||
.withMessage ("You picked: " + name)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
});
|
||||
}
|
||||
else if (type == directoryChooser)
|
||||
|
|
@ -420,9 +432,12 @@ private:
|
|||
auto name = result.isLocalFile() ? result.getLocalFile().getFullPathName()
|
||||
: result.toString (true);
|
||||
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
|
||||
"File Chooser...",
|
||||
"You picked: " + name);
|
||||
AlertWindow::showAsync (MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("File Chooser...")
|
||||
.withMessage ("You picked: " + name)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -433,8 +448,12 @@ private:
|
|||
{
|
||||
auto resultString = success ? String ("success") : ("failure\n (error: " + error + ")");
|
||||
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, "Sharing Text Result",
|
||||
"Sharing text finished\nwith " + resultString);
|
||||
AlertWindow::showAsync (MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Sharing Text Result")
|
||||
.withMessage ("Sharing text finished\nwith " + resultString)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
});
|
||||
}
|
||||
else if (type == shareFile)
|
||||
|
|
@ -454,9 +473,12 @@ private:
|
|||
{
|
||||
auto resultString = success ? String ("success") : ("failure\n (error: " + error + ")");
|
||||
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
|
||||
"Sharing Files Result",
|
||||
"Sharing files finished\nwith " + resultString);
|
||||
AlertWindow::showAsync (MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Sharing Files Result")
|
||||
.withMessage ("Sharing files finished\nwith " + resultString)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -480,8 +502,12 @@ private:
|
|||
String resultString = success ? String ("success")
|
||||
: ("failure\n (error: " + error + ")");
|
||||
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, "Sharing Images Result",
|
||||
"Sharing images finished\nwith " + resultString);
|
||||
AlertWindow::showAsync (MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Sharing Images Result")
|
||||
.withMessage ("Sharing images finished\nwith " + resultString)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public:
|
|||
void buttonClicked() override
|
||||
{
|
||||
++counter;
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon, "Action Button Pressed",
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::InfoIcon, "Action Button Pressed",
|
||||
"Pressing this type of property component can trigger an action such as showing an alert window!");
|
||||
refresh();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ private:
|
|||
}
|
||||
else
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
|
||||
"Couldn't load the file!",
|
||||
result.getErrorMessage());
|
||||
}
|
||||
|
|
@ -354,7 +354,7 @@ public:
|
|||
{
|
||||
if (! granted)
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
|
||||
"Permissions warning",
|
||||
"External storage access permission not granted, some files"
|
||||
" may be inaccessible.");
|
||||
|
|
@ -503,7 +503,7 @@ private:
|
|||
|
||||
void askIfUseNativeControls (const URL& url)
|
||||
{
|
||||
auto* aw = new AlertWindow ("Choose viewer type", {}, AlertWindow::NoIcon);
|
||||
auto* aw = new AlertWindow ("Choose viewer type", {}, MessageBoxIconType::NoIcon);
|
||||
|
||||
aw->addButton ("Yes", 1, KeyPress (KeyPress::returnKey));
|
||||
aw->addButton ("No", 0, KeyPress (KeyPress::escapeKey));
|
||||
|
|
@ -559,7 +559,7 @@ private:
|
|||
|
||||
void showVideoUrlPrompt()
|
||||
{
|
||||
auto* aw = new AlertWindow ("Enter URL for video to load", {}, AlertWindow::NoIcon);
|
||||
auto* aw = new AlertWindow ("Enter URL for video to load", {}, MessageBoxIconType::NoIcon);
|
||||
|
||||
aw->addButton ("OK", 1, KeyPress (KeyPress::returnKey));
|
||||
aw->addButton ("Cancel", 0, KeyPress (KeyPress::escapeKey));
|
||||
|
|
@ -596,7 +596,7 @@ private:
|
|||
}
|
||||
else
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
|
||||
"Couldn't load the file!",
|
||||
result.getErrorMessage());
|
||||
}
|
||||
|
|
@ -677,7 +677,7 @@ private:
|
|||
|
||||
void errorOccurred (const String& errorMessage)
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::InfoIcon,
|
||||
"An error has occurred",
|
||||
errorMessage + ", video will be unloaded.");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue