X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0ddea946963af702917b80861d63544dda0eb334..d93c719ac09362890adde4f6f0e5962aed816280:/samples/text/text.cpp diff --git a/samples/text/text.cpp b/samples/text/text.cpp index 09e8e6013d..f534553804 100644 --- a/samples/text/text.cpp +++ b/samples/text/text.cpp @@ -29,7 +29,7 @@ #endif #if wxUSE_FILE - #include "wx/file.h" + #include "wx/file.h" #endif #if wxUSE_TOOLTIPS @@ -66,6 +66,7 @@ public: void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event); void OnChar(wxKeyEvent& event); + void OnText(wxCommandEvent& event); bool m_hasCapture; @@ -159,7 +160,7 @@ enum TEXT_QUIT = 100, TEXT_ABOUT, TEXT_LOAD, - TEXT_SAVE, + TEXT_SAVE, TEXT_CLEAR, // clipboard menu @@ -239,6 +240,7 @@ BEGIN_EVENT_TABLE(MyTextCtrl, wxTextCtrl) EVT_KEY_DOWN(MyTextCtrl::OnKeyDown) EVT_KEY_UP(MyTextCtrl::OnKeyUp) EVT_CHAR(MyTextCtrl::OnChar) + EVT_TEXT(-1, MyTextCtrl::OnText) END_EVENT_TABLE() void MyTextCtrl::LogEvent(const wxChar *name, wxKeyEvent& event) const @@ -370,6 +372,16 @@ void MyTextCtrl::LogEvent(const wxChar *name, wxKeyEvent& event) const } +void MyTextCtrl::OnText(wxCommandEvent& event) +{ + MyTextCtrl *win = (MyTextCtrl *)event.GetEventObject(); + const wxChar *data = (const wxChar *)(win->GetClientData()); + if ( data ) + { + wxLogMessage(_T("text changed in control '%s'"), data); + } +} + void MyTextCtrl::OnChar(wxKeyEvent& event) { LogEvent( _T("Char"), event); @@ -390,7 +402,7 @@ void MyTextCtrl::OnChar(wxKeyEvent& event) void MyTextCtrl::OnKeyUp(wxKeyEvent& event) { - LogEvent( _("Key up"), event); + LogEvent( _T("Key up"), event); event.Skip(); } @@ -446,10 +458,10 @@ void MyTextCtrl::OnKeyDown(wxKeyEvent& event) case WXK_F5: // insert a blank line WriteText("\n"); - break; + break; - default: - LogEvent( _("Key down"), event); + default: + LogEvent( wxT("Key down"), event); } event.Skip(); @@ -503,11 +515,13 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_multitext->SetToolTip("Press F1 here for statitics, F4 for capture and uncapture mouse."); #endif - m_tab = new MyTextCtrl( this, -1, "Multiline, allow processing.", + m_tab = new MyTextCtrl( this, 100, "Multiline, allow processing.", wxPoint(180,90), wxSize(240,70), wxTE_MULTILINE | wxTE_PROCESS_TAB ); + m_tab->SetClientData(_T("tab")); - m_enter = new MyTextCtrl( this, -1, "Multiline, allow processing.", + m_enter = new MyTextCtrl( this, 100, "Multiline, allow processing.", wxPoint(180,170), wxSize(240,70), wxTE_MULTILINE); + m_enter->SetClientData(_T("enter")); m_textrich = new MyTextCtrl(this, -1, "Allows more than 30Kb of text\n" "(even under broken Win9x)",