mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
Playground: Set editor->on_change
before opening files
Set `editor->on_change` callback before opening files, otherwise the compiled GML preview will only be available after some manual input in the text editor.
This commit is contained in:
parent
4fbe43f282
commit
c9ed88309b
1 changed files with 12 additions and 12 deletions
|
@ -109,6 +109,18 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_title(builder.to_string());
|
||||
};
|
||||
|
||||
editor->on_change = [&] {
|
||||
preview->remove_all_children();
|
||||
preview->load_from_gml(editor->text(), [](const String& class_name) -> RefPtr<Core::Object> {
|
||||
return UnregisteredWidget::construct(class_name);
|
||||
});
|
||||
};
|
||||
|
||||
editor->on_modified_change = [&](bool modified) {
|
||||
window->set_modified(modified);
|
||||
update_title();
|
||||
};
|
||||
|
||||
if (String(path).is_empty()) {
|
||||
editor->set_text(R"~~~(@GUI::Frame {
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
|
@ -134,18 +146,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
update_title();
|
||||
}
|
||||
|
||||
editor->on_change = [&] {
|
||||
preview->remove_all_children();
|
||||
preview->load_from_gml(editor->text(), [](const String& class_name) -> RefPtr<Core::Object> {
|
||||
return UnregisteredWidget::construct(class_name);
|
||||
});
|
||||
};
|
||||
|
||||
editor->on_modified_change = [&](bool modified) {
|
||||
window->set_modified(modified);
|
||||
update_title();
|
||||
};
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"));
|
||||
|
||||
auto save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue