cpp/TextBox.cpp
changeset 6 66becdcbe5d9
parent 5 f2a2f64eb682
equal deleted inserted replaced
5:f2a2f64eb682 6:66becdcbe5d9
     3 #include "MainWindow.hpp"
     3 #include "MainWindow.hpp"
     4 
     4 
     5 BEGIN_EVENT_TABLE (wxTextBox, wxTextCtrl)
     5 BEGIN_EVENT_TABLE (wxTextBox, wxTextCtrl)
     6     EVT_CHAR (wxTextBox::OnKeyEvent)
     6     EVT_CHAR (wxTextBox::OnKeyEvent)
     7 END_EVENT_TABLE ()
     7 END_EVENT_TABLE ()
     8 
       
     9 
     8 
    10 wxTextBox::wxTextBox(wxWindow *parent, int id, wxString text)
     9 wxTextBox::wxTextBox(wxWindow *parent, int id, wxString text)
    11     :wxTextCtrl(parent, id, text, wxDefaultPosition, wxDefaultSize,
    10     :wxTextCtrl(parent, id, text, wxDefaultPosition, wxDefaultSize,
    12             wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB)
    11             wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB)
    13 {
    12 {
    16 void wxTextBox::OnKeyEvent(wxKeyEvent &e)
    15 void wxTextBox::OnKeyEvent(wxKeyEvent &e)
    17 {
    16 {
    18     if (e.GetKeyCode() == WXK_TAB)
    17     if (e.GetKeyCode() == WXK_TAB)
    19     {
    18     {
    20         std::cerr << "TAB pressed" << std::endl;
    19         std::cerr << "TAB pressed" << std::endl;
    21         wxCommandEvent ce(MainWindow::ID_SKIP_QUESTION);
    20         wxCommandEvent ce(EV_SKIP_QUESTION);
    22         AddPendingEvent(ce);
    21         AddPendingEvent(ce);
    23     }
    22     }
    24     else if (e.GetKeyCode() == WXK_RETURN)
    23     else if (e.GetKeyCode() == WXK_RETURN)
    25     {
    24     {
    26         std::cerr << "ENTER pressed" << std::endl;
    25         std::cerr << "ENTER pressed" << std::endl;
    27         wxCommandEvent ce(MainWindow::ID_SAVE_SENTENCE);
    26         wxCommandEvent ce(EV_SAVE_SENTENCE);
    28         AddPendingEvent(ce);
    27         AddPendingEvent(ce);
    29     }
    28     }
    30     else
    29     else
    31         e.Skip();
    30         e.Skip();
    32 }
    31 }