# HG changeset patch # User viric # Date 1297582986 -3600 # Node ID f2a2f64eb682cd5c0318bf926bee4c8f3b6ffe31 # Parent a3d29fb016c3f666271a3a0f6c91d108b37051a3 Events don't work as I expect. tab makes save sentence, while enter should be doing that. diff -r a3d29fb016c3 -r f2a2f64eb682 cpp/MainWindow.cpp --- a/cpp/MainWindow.cpp Sun Feb 13 08:27:44 2011 +0100 +++ b/cpp/MainWindow.cpp Sun Feb 13 08:43:06 2011 +0100 @@ -1,10 +1,17 @@ #include #include +#include #include "MainWindow.hpp" #include "TextBox.hpp" +BEGIN_EVENT_TABLE (MainWindow, wxFrame) + EVT_COMMAND (wxID_ANY, ID_SKIP_QUESTION, MainWindow::OnSkipQuestion ) + EVT_COMMAND (wxID_ANY, ID_SAVE_SENTENCE, MainWindow::OnSaveSentence ) +END_EVENT_TABLE () + MainWindow::MainWindow() - :wxFrame(0, wxID_ANY, _("Lingvigilo"), wxDefaultPosition) + :wxFrame(0, wxID_ANY, _("Lingvigilo"), wxDefaultPosition, wxDefaultSize, + wxSTAY_ON_TOP) { wxBoxSizer *s = new wxBoxSizer(wxVERTICAL); wxStaticText *label = new wxStaticText(this, wxID_ANY, @@ -17,3 +24,15 @@ SetSizerAndFit(s); } + +void +MainWindow::OnSkipQuestion(wxCommandEvent &e) +{ + std::cerr << "Skip Question" << std::endl; +} + +void +MainWindow::OnSaveSentence(wxCommandEvent &e) +{ + std::cerr << "Save Sentence" << std::endl; +} diff -r a3d29fb016c3 -r f2a2f64eb682 cpp/MainWindow.hpp --- a/cpp/MainWindow.hpp Sun Feb 13 08:27:44 2011 +0100 +++ b/cpp/MainWindow.hpp Sun Feb 13 08:43:06 2011 +0100 @@ -2,11 +2,23 @@ #define _HEADER_MAINWINDOW_HPP_ #include +#include class MainWindow : public wxFrame { -public: - MainWindow(); + public: + enum + { + ID_SKIP_QUESTION, + ID_SAVE_SENTENCE + }; + + MainWindow(); + + void OnSkipQuestion(wxCommandEvent &e); + void OnSaveSentence(wxCommandEvent &e); + + DECLARE_EVENT_TABLE(); }; #endif /* _HEADER_MAINWINDOW_HPP_ */ diff -r a3d29fb016c3 -r f2a2f64eb682 cpp/TextBox.cpp --- a/cpp/TextBox.cpp Sun Feb 13 08:27:44 2011 +0100 +++ b/cpp/TextBox.cpp Sun Feb 13 08:43:06 2011 +0100 @@ -1,5 +1,6 @@ #include #include "TextBox.hpp" +#include "MainWindow.hpp" BEGIN_EVENT_TABLE (wxTextBox, wxTextCtrl) EVT_CHAR (wxTextBox::OnKeyEvent) @@ -17,10 +18,14 @@ if (e.GetKeyCode() == WXK_TAB) { std::cerr << "TAB pressed" << std::endl; + wxCommandEvent ce(MainWindow::ID_SKIP_QUESTION); + AddPendingEvent(ce); } else if (e.GetKeyCode() == WXK_RETURN) { std::cerr << "ENTER pressed" << std::endl; + wxCommandEvent ce(MainWindow::ID_SAVE_SENTENCE); + AddPendingEvent(ce); } else e.Skip();