-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathTextEntryDialog.cpp
More file actions
30 lines (26 loc) · 991 Bytes
/
TextEntryDialog.cpp
File metadata and controls
30 lines (26 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <wx/app.h>
#include <wx/button.h>
#include <wx/frame.h>
#include <wx/panel.h>
#include <wx/stattext.h>
#include <wx/textdlg.h>
namespace TextEntryDialogExample {
class Frame : public wxFrame {
public:
Frame() : wxFrame {nullptr, wxID_ANY, "TextEntryDialog example"} {
button->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event) {
auto textEntryDialog = wxTextEntryDialog {this, "Message text", "Caption text", label->GetLabel(), wxTextEntryDialogStyle};
if (textEntryDialog.ShowModal() == wxID_OK)
label->SetLabel(textEntryDialog.GetValue());
});
}
private:
wxPanel* panel = new wxPanel {this};
wxButton* button = new wxButton {panel, wxID_ANY, "Text...", {10, 10}};
wxStaticText* label = new wxStaticText {panel, wxID_ANY, "Default value", {10, 50}};
};
class Application : public wxApp {
auto OnInit() -> bool override {return (new Frame)->Show();}
};
}
wxIMPLEMENT_APP(TextEntryDialogExample::Application);