Fixed bug with Copy/Paste in Primary Selection in Text Viewers
authorLaurent Bessard
Mon, 13 May 2013 16:38:53 +0200
changeset 1126 26baa0ae9fd7
parent 1125 1b1472e76f07
child 1127 5315f26642e0
Fixed bug with Copy/Paste in Primary Selection in Text Viewers
editors/CodeFileEditor.py
editors/TextViewer.py
--- a/editors/CodeFileEditor.py	Mon May 13 14:36:54 2013 +0200
+++ b/editors/CodeFileEditor.py	Mon May 13 16:38:53 2013 +0200
@@ -313,7 +313,7 @@
         self.AutoCompCancel()
         event.Skip()
 
-    def OnUpdateUI(self, evt):
+    def OnUpdateUI(self, event):
         # check for matching braces
         braceAtCaret = -1
         braceOpposite = -1
@@ -343,8 +343,11 @@
             self.BraceBadLight(braceAtCaret)
         else:
             self.BraceHighlight(braceAtCaret, braceOpposite)
-
-    def OnMarginClick(self, evt):
+            
+        self.ParentWindow.SetCopyBuffer(self.GetSelectedText(), True)
+        event.Skip()
+
+    def OnMarginClick(self, event):
         # fold and unfold as needed
         if evt.GetMargin() == 2:
             if evt.GetShift() and evt.GetControl():
@@ -365,7 +368,7 @@
                             self.Expand(lineClicked, True, True, 100)
                     else:
                         self.ToggleFold(lineClicked)
-
+        event.Skip()
 
     def FoldAll(self):
         lineCount = self.GetLineCount()
--- a/editors/TextViewer.py	Mon May 13 14:36:54 2013 +0200
+++ b/editors/TextViewer.py	Mon May 13 16:38:53 2013 +0200
@@ -141,6 +141,7 @@
 
         self.Bind(wx.stc.EVT_STC_STYLENEEDED, self.OnStyleNeeded, id=ID_TEXTVIEWERTEXTCTRL)
         self.Editor.Bind(wx.stc.EVT_STC_MARGINCLICK, self.OnMarginClick)
+        self.Editor.Bind(wx.stc.EVT_STC_UPDATEUI, self.OnUpdateUI)
         self.Editor.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
         if self.Controler is not None:
             self.Editor.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
@@ -714,7 +715,12 @@
             if self.Editor.GetFoldLevel(line) & wx.stc.STC_FOLDLEVELHEADERFLAG:
                 self.Editor.ToggleFold(line)
         event.Skip()
-        
+    
+    def OnUpdateUI(self, event):
+        if self.ParentWindow:
+            self.ParentWindow.SetCopyBuffer(self.Editor.GetSelectedText(), True)
+        event.Skip()
+    
     def Cut(self):
         self.ResetBuffer()
         self.DisableEvents = True
@@ -725,6 +731,8 @@
     
     def Copy(self):
         self.Editor.CmdKeyExecute(wx.stc.STC_CMD_COPY)
+        if self.ParentWindow:
+            self.ParentWindow.RefreshEditMenu()
     
     def Paste(self):
         self.ResetBuffer()