|
@@ -36,9 +36,9 @@ void GInputBox::build()
|
|
|
label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
|
|
label->set_preferred_size({ text_width, 16 });
|
|
|
|
|
|
- auto* text_editor = new GTextEditor(GTextEditor::SingleLine, widget);
|
|
|
- text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
|
- text_editor->set_preferred_size({ 0, 16 });
|
|
|
+ m_text_editor = new GTextEditor(GTextEditor::SingleLine, widget);
|
|
|
+ m_text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
|
+ m_text_editor->set_preferred_size({ 0, 16 });
|
|
|
|
|
|
auto* button_container_outer = new GWidget(widget);
|
|
|
button_container_outer->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
|
@@ -47,30 +47,30 @@ void GInputBox::build()
|
|
|
button_container_inner->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
|
|
button_container_inner->layout()->set_spacing(8);
|
|
|
|
|
|
- auto* cancel_button = new GButton(button_container_inner);
|
|
|
- cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
|
- cancel_button->set_preferred_size({ 0, 16 });
|
|
|
- cancel_button->set_caption("Cancel");
|
|
|
- cancel_button->on_click = [&] (auto&) {
|
|
|
- fprintf(stderr, "GInputBox: Cancel button clicked\n");
|
|
|
- done(1);
|
|
|
+ m_cancel_button = new GButton(button_container_inner);
|
|
|
+ m_cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
|
+ m_cancel_button->set_preferred_size({ 0, 16 });
|
|
|
+ m_cancel_button->set_caption("Cancel");
|
|
|
+ m_cancel_button->on_click = [this] (auto&) {
|
|
|
+ dbgprintf("GInputBox: Cancel button clicked\n");
|
|
|
+ done(ExecCancel);
|
|
|
};
|
|
|
|
|
|
- auto* ok_button = new GButton(button_container_inner);
|
|
|
- ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
|
- ok_button->set_preferred_size({ 0, 16 });
|
|
|
- ok_button->set_caption("OK");
|
|
|
- ok_button->on_click = [&] (auto&) {
|
|
|
- fprintf(stderr, "GInputBox: OK button clicked\n");
|
|
|
- m_text_value = text_editor->text();
|
|
|
- done(0);
|
|
|
+ m_ok_button = new GButton(button_container_inner);
|
|
|
+ m_ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
|
+ m_ok_button->set_preferred_size({ 0, 16 });
|
|
|
+ m_ok_button->set_caption("OK");
|
|
|
+ m_ok_button->on_click = [this] (auto&) {
|
|
|
+ dbgprintf("GInputBox: OK button clicked\n");
|
|
|
+ m_text_value = m_text_editor->text();
|
|
|
+ done(ExecOK);
|
|
|
};
|
|
|
|
|
|
- text_editor->on_return_pressed = [&] (auto&) {
|
|
|
- ok_button->click();
|
|
|
+ m_text_editor->on_return_pressed = [this] (auto&) {
|
|
|
+ m_ok_button->click();
|
|
|
};
|
|
|
- text_editor->on_escape_pressed = [&] (auto&) {
|
|
|
- cancel_button->click();
|
|
|
+ m_text_editor->on_escape_pressed = [this] (auto&) {
|
|
|
+ m_cancel_button->click();
|
|
|
};
|
|
|
- text_editor->set_focus(true);
|
|
|
+ m_text_editor->set_focus(true);
|
|
|
}
|