The Battle for Wesnoth  1.19.5+dev
prompt.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2023 - 2024
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
17 #include "gui/dialogs/prompt.hpp"
18 
19 #include "gui/widgets/text_box.hpp"
20 
21 namespace gui2::dialogs
22 {
23 
24 REGISTER_DIALOG(prompt)
25 
26 prompt::prompt(std::string& value)
27  : modal_dialog(window_id())
28  , value_(value)
29 {
30  find_widget<text_box>("prompt_box").set_value(value);
31 }
32 
34 {
35  text_box* prompt_box = find_widget<text_box>("prompt_box", false, true);
36  keyboard_capture(prompt_box);
37 }
38 
40 {
41  value_ = find_widget<text_box>("prompt_box").get_value();
42 }
43 
44 } // namespace gui2::dialogs
Abstract base class for all modal dialogs.
std::string & value_
Definition: prompt.hpp:39
virtual void pre_show() override
The execute function.
Definition: prompt.cpp:33
virtual void post_show() override
Actions to be taken after the window has been shown.
Definition: prompt.cpp:39
A widget that allows the user to input text in single line.
Definition: text_box.hpp:125
void keyboard_capture(widget *widget)
Definition: window.cpp:1207
REGISTER_DIALOG(editor_edit_unit)