mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:38:10 +00:00
LibGUI: Add InputBox::show with required parent window argument
Similar to MessageBox::show, this encourages passing in a window.
This commit is contained in:
parent
27bd2eab22
commit
65a11fb5f9
11 changed files with 99 additions and 94 deletions
|
@ -203,10 +203,9 @@ int main(int argc, char** argv)
|
|||
};
|
||||
|
||||
auto new_action = GUI::Action::create("Add new file to project...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) {
|
||||
auto input_box = GUI::InputBox::construct("Enter name of new file:", "Add new file to project", g_window);
|
||||
if (input_box->exec() == GUI::InputBox::ExecCancel)
|
||||
String filename;
|
||||
if (GUI::InputBox::show(filename, g_window, "Enter name of new file:", "Add new file to project") != GUI::InputBox::ExecOK)
|
||||
return;
|
||||
auto filename = input_box->text_value();
|
||||
auto file = Core::File::construct(filename);
|
||||
if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) {
|
||||
GUI::MessageBox::show(g_window, String::format("Failed to create '%s'", filename.characters()), "Error", GUI::MessageBox::Type::Error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue