]> git.saurik.com Git - wxWidgets.git/commitdiff
don't bounce back events to the text control recursively as this results in infinite...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Apr 2008 17:02:25 +0000 (17:02 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Apr 2008 17:02:25 +0000 (17:02 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53062 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/docview/view.cpp
samples/docview/view.h
samples/docvwmdi/view.cpp
samples/docvwmdi/view.h

index d2a02dccdb24319ef7770dedb9f3cf6fcffc919d..5a4d9e63bc619406218d7d1497c9b9d7e942332b 100644 (file)
@@ -156,6 +156,12 @@ void DrawingView::OnCut(wxCommandEvent& WXUNUSED(event) )
 
 IMPLEMENT_DYNAMIC_CLASS(TextEditView, wxView)
 
 
 IMPLEMENT_DYNAMIC_CLASS(TextEditView, wxView)
 
+BEGIN_EVENT_TABLE(TextEditView, wxView)
+    EVT_MENU(wxID_COPY, TextEditView::OnCopy)
+    EVT_MENU(wxID_PASTE, TextEditView::OnPaste)
+    EVT_MENU(wxID_SELECTALL, TextEditView::OnSelectAll)
+END_EVENT_TABLE()
+
 bool TextEditView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
 {
     m_frame = wxGetApp().CreateChildFrame(doc, this, false);
 bool TextEditView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
 {
     m_frame = wxGetApp().CreateChildFrame(doc, this, false);
@@ -201,21 +207,6 @@ bool TextEditView::OnClose(bool deleteWindow)
     return true;
 }
 
     return true;
 }
 
-bool TextEditView::ProcessEvent(wxEvent& event)
-{
-    bool processed = false;
-    if (!processed) switch (event.GetId())
-    {
-        case wxID_COPY:
-        case wxID_PASTE:
-        case wxID_SELECTALL:
-            processed = m_textsw->ProcessEvent(event);
-            break;
-    }
-    if (!processed) processed = wxView::ProcessEvent(event);
-    return processed;
-}
-
 /*
 * Window implementations
 */
 /*
 * Window implementations
 */
index b956daadeb9f53cb9da76c992fef492ca1314116..3c3fd2c240dac00595de46fc746655e33fe6182e 100644 (file)
@@ -73,9 +73,13 @@ public:
     virtual void OnDraw(wxDC *dc);
     virtual void OnUpdate(wxView *sender, wxObject *hint = NULL);
     virtual bool OnClose(bool deleteWindow = true);
     virtual void OnDraw(wxDC *dc);
     virtual void OnUpdate(wxView *sender, wxObject *hint = NULL);
     virtual bool OnClose(bool deleteWindow = true);
-    virtual bool ProcessEvent(wxEvent&);
 
 private:
 
 private:
+    void OnCopy(wxCommandEvent& WXUNUSED(event)) { m_textsw->Copy(); }
+    void OnPaste(wxCommandEvent& WXUNUSED(event)) { m_textsw->Paste(); }
+    void OnSelectAll(wxCommandEvent& WXUNUSED(event)) { m_textsw->SelectAll(); }
+
+    DECLARE_EVENT_TABLE()
     DECLARE_DYNAMIC_CLASS(TextEditView)
 };
 
     DECLARE_DYNAMIC_CLASS(TextEditView)
 };
 
index bb2c0df2973ac33d05cd4abc37935af0c1efff0b..51cfde610c75b87677532ba02ce31d91546a59bf 100644 (file)
@@ -135,6 +135,12 @@ void DrawingView::OnCut(wxCommandEvent& WXUNUSED(event) )
 
 IMPLEMENT_DYNAMIC_CLASS(TextEditView, wxView)
 
 
 IMPLEMENT_DYNAMIC_CLASS(TextEditView, wxView)
 
+BEGIN_EVENT_TABLE(TextEditView, wxView)
+    EVT_MENU(wxID_COPY, TextEditView::OnCopy)
+    EVT_MENU(wxID_PASTE, TextEditView::OnPaste)
+    EVT_MENU(wxID_SELECTALL, TextEditView::OnSelectAll)
+END_EVENT_TABLE()
+
 bool TextEditView::OnCreate(wxDocument* doc, long WXUNUSED(flags) )
 {
     m_frame = wxGetApp().CreateChildFrame(doc, this, false);
 bool TextEditView::OnCreate(wxDocument* doc, long WXUNUSED(flags) )
 {
     m_frame = wxGetApp().CreateChildFrame(doc, this, false);
index d146d8cff4225de9c6deb566ba3786b3b5b0ef2c..8ac7c98ca9bccdd425151e48fb84e159dc4ac628 100644 (file)
@@ -60,7 +60,6 @@ protected:
 
 class TextEditView: public wxView
 {
 
 class TextEditView: public wxView
 {
-    DECLARE_DYNAMIC_CLASS(TextEditView)
 public:
     wxMDIChildFrame* m_frame;
     MyTextWindow* m_textsw;
 public:
     wxMDIChildFrame* m_frame;
     MyTextWindow* m_textsw;
@@ -73,6 +72,14 @@ public:
     virtual void OnUpdate(wxView *sender, wxObject *hint = NULL);
     virtual bool OnClose(bool deleteWindow = true);
     virtual bool ProcessEvent(wxEvent&);
     virtual void OnUpdate(wxView *sender, wxObject *hint = NULL);
     virtual bool OnClose(bool deleteWindow = true);
     virtual bool ProcessEvent(wxEvent&);
+
+private:
+    void OnCopy(wxCommandEvent& WXUNUSED(event)) { m_textsw->Copy(); }
+    void OnPaste(wxCommandEvent& WXUNUSED(event)) { m_textsw->Paste(); }
+    void OnSelectAll(wxCommandEvent& WXUNUSED(event)) { m_textsw->SelectAll(); }
+
+    DECLARE_EVENT_TABLE()
+    DECLARE_DYNAMIC_CLASS(TextEditView)
 };
 
 #endif
 };
 
 #endif