cpp/TextBox.cpp
author viric <viriketo@gmail.com>
Sun, 13 Feb 2011 22:51:39 +0100
changeset 6 66becdcbe5d9
parent 5 f2a2f64eb682
permissions -rw-r--r--
Ara em va allò dels events
#include <iostream>
#include "TextBox.hpp"
#include "MainWindow.hpp"

BEGIN_EVENT_TABLE (wxTextBox, wxTextCtrl)
    EVT_CHAR (wxTextBox::OnKeyEvent)
END_EVENT_TABLE ()

wxTextBox::wxTextBox(wxWindow *parent, int id, wxString text)
    :wxTextCtrl(parent, id, text, wxDefaultPosition, wxDefaultSize,
            wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB)
{
}

void wxTextBox::OnKeyEvent(wxKeyEvent &e)
{
    if (e.GetKeyCode() == WXK_TAB)
    {
        std::cerr << "TAB pressed" << std::endl;
        wxCommandEvent ce(EV_SKIP_QUESTION);
        AddPendingEvent(ce);
    }
    else if (e.GetKeyCode() == WXK_RETURN)
    {
        std::cerr << "ENTER pressed" << std::endl;
        wxCommandEvent ce(EV_SAVE_SENTENCE);
        AddPendingEvent(ce);
    }
    else
        e.Skip();
}