+}
+
+static wxString GetMouseEventDesc(const wxMouseEvent& ev)
+{
+ // click event
+ wxString button;
+ bool dbl, up;
+ if ( ev.LeftDown() || ev.LeftUp() || ev.LeftDClick() )
+ {
+ button = _T("Left");
+ dbl = ev.LeftDClick();
+ up = ev.LeftUp();
+ }
+ else if ( ev.MiddleDown() || ev.MiddleUp() || ev.MiddleDClick() )
+ {
+ button = _T("Middle");
+ dbl = ev.MiddleDClick();
+ up = ev.MiddleUp();
+ }
+ else if ( ev.RightDown() || ev.RightUp() || ev.RightDClick() )
+ {
+ button = _T("Right");
+ dbl = ev.RightDClick();
+ up = ev.RightUp();
+ }
+ else
+ {
+ return _T("Unknown mouse event");
+ }
+
+ return wxString::Format(_T("%s mouse button %s"),
+ button.c_str(),
+ dbl ? _T("double clicked")
+ : up ? _T("released") : _T("clicked"));
+}
+
+void MyTextCtrl::OnMouseEvent(wxMouseEvent& ev)
+{
+ if ( !ev.Moving() )
+ {
+ wxString msg;
+ if ( ev.Entering() )
+ {
+ msg = _T("Mouse entered the window");
+ }
+ else if ( ev.Leaving() )
+ {
+ msg = _T("Mouse left the window");
+ }
+ else
+ {
+ msg = GetMouseEventDesc(ev);
+ }
+
+ msg << _T(" at (") << ev.GetX() << _T(", ") << ev.GetY() << _T(") ")
+ << _T("Flags: ")
+ << GetChar( ev.LeftIsDown(), _T('1') )
+ << GetChar( ev.MiddleIsDown(), _T('2') )
+ << GetChar( ev.RightIsDown(), _T('3') )
+ << GetChar( ev.ControlDown(), _T('C') )
+ << GetChar( ev.AltDown(), _T('A') )
+ << GetChar( ev.ShiftDown(), _T('S') )
+ << GetChar( ev.MetaDown(), _T('M') );
+
+ wxLogMessage(msg);
+ }
+ //else: we're not interested in mouse move events
+
+ ev.Skip();
+}
+
+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);
+ }
+ else
+ {
+ wxLogMessage(_T("Text changed in some control"));
+ }
+}
+
+void MyTextCtrl::OnTextURL(wxTextUrlEvent& event)
+{
+ const wxMouseEvent& ev = event.GetMouseEvent();
+
+ // filter out mouse moves, too many of them
+ if ( ev.Moving() )
+ return;