cpp/TextBox.cpp
author viric <viriketo@gmail.com>
Sun, 13 Feb 2011 08:27:44 +0100
changeset 4 a3d29fb016c3
child 5 f2a2f64eb682
permissions -rw-r--r--
Adding handling of tab and enter
#include <iostream>
#include "TextBox.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;
    }
    else if (e.GetKeyCode() == WXK_RETURN)
    {
        std::cerr << "ENTER pressed" << std::endl;
    }
    else
        e.Skip();
}