PLCOpenEditor.py
changeset 384 ed27a676d5c9
parent 372 8cab11dd2325
child 390 020420ad8914
--- a/PLCOpenEditor.py	Fri Jul 24 10:47:35 2009 +0200
+++ b/PLCOpenEditor.py	Fri Jul 24 11:07:33 2009 +0200
@@ -177,8 +177,7 @@
 
 class PLCOpenEditor(wx.Frame):
     
-    CopyBuffer = None
-    
+    # Compatibility function for wx versions < 2.6
     if wx.VERSION < (2, 6, 0):
         def Bind(self, event, function, id = None):
             if id is not None:
@@ -689,10 +688,21 @@
         event.Skip()
 
     def GetCopyBuffer(self):
-        return PLCOpenEditor.CopyBuffer
-    
-    def SetCopyBuffer(self, element):
-        PLCOpenEditor.CopyBuffer = element
+        data = None
+        if wx.TheClipboard.Open():
+            dataobj = wx.TextDataObject()
+            if wx.TheClipboard.GetData(dataobj):
+                data = dataobj.GetText()
+            wx.TheClipboard.Close()
+        return data
+        
+    def SetCopyBuffer(self, text):
+        if wx.TheClipboard.Open():
+            data = wx.TextDataObject()
+            data.SetText(text)
+            wx.TheClipboard.SetData(data)
+            wx.TheClipboard.Flush()
+            wx.TheClipboard.Close()
         self.RefreshEditMenu()
 
     def GetDrawingMode(self):
@@ -1071,7 +1081,7 @@
                 if self.TabsOpened.GetPageCount() > 0:
                     self.EditMenu.Enable(wx.ID_CUT, True)
                     self.EditMenu.Enable(wx.ID_COPY, True)
-                    if self.CopyBuffer is not None:
+                    if self.GetCopyBuffer() is not None:
                         self.EditMenu.Enable(wx.ID_PASTE, True)
                     else:
                         self.EditMenu.Enable(wx.ID_PASTE, False)