Hier ein einfaches Beispiel, mein Custom Event wird nicht ausgelöst. Was mache ich falsch? Das Bindung auf "onButton" wird ausgeführt.
1 | #include "mainwindow.hpp" |
2 | |
3 | wxDECLARE_EVENT(CUSTOMEVENT_SERIAL2, wxCommandEvent); |
4 | wxDEFINE_EVENT(CUSTOMEVENT_SERIAL2, wxCommandEvent); |
5 | |
6 | |
7 | MainWindow::MainWindow() : wxFrame(nullptr, 5, "test"){ |
8 | /*Steuerelemente*/ |
9 | wxBoxSizer* layoutMain = new wxBoxSizer(wxHORIZONTAL); |
10 | |
11 | /*Linkes Menu*/ |
12 | wxBoxSizer* layoutLeft = new wxBoxSizer(wxVERTICAL); |
13 | layoutLeft->Add(new wxButton(this, 6, "button"), 1, wxEXPAND, 0); |
14 | layoutMain->Add(layoutLeft, 1, wxEXPAND, 0); |
15 | |
16 | |
17 | SetSizerAndFit(layoutMain); |
18 | |
19 | Bind(CUSTOMEVENT_SERIAL2, [this](wxCommandEvent& event) { |
20 | std::string s("C998\n"); |
21 | recv.send(s.c_str(), s.length()); |
22 | }); |
23 | |
24 | Bind(wxEVT_BUTTON, &MainWindow::onButton, this); |
25 | } |
26 | |
27 | void MainWindow::onButton(wxCommandEvent& event) { |
28 | wxCommandEvent evt2(this->GetId(), CUSTOMEVENT_SERIAL2); |
29 | wxPostEvent(this, evt2); |
30 | } |