فهرست منبع

fix copy-to-clipboard key binding on macOS (#393)

* fixes trac issue https://trac.osgeo.org/grass/ticket/3008,
binding cmd+c to copy-to-clipboard in output console and
python shell

* fixes trac issue https://trac.osgeo.org/grass/ticket/3592,
binding cmd+c to copy-to-clipboard import/export dialogs
nilason 5 سال پیش
والد
کامیت
eab5803460
2فایلهای تغییر یافته به همراه29 افزوده شده و 0 حذف شده
  1. 14 0
      gui/wxpython/lmgr/frame.py
  2. 15 0
      gui/wxpython/modules/import_export.py

+ 14 - 0
gui/wxpython/lmgr/frame.py

@@ -250,6 +250,13 @@ class GMFrame(wx.Frame):
 
 
         show_menu_errors(menu_errors)
         show_menu_errors(menu_errors)
 
 
+        # Enable copying to clipboard with cmd+c from console and python shell on macOS
+        # (default key binding will clear the console), trac #3008
+        if sys.platform == "darwin":
+            self.Bind(wx.EVT_MENU, self.OnCopyToClipboard, id=wx.ID_COPY)
+            self.accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord("C"), wx.ID_COPY)])
+            self.SetAcceleratorTable(self.accel_tbl)
+
         # start with layer manager on top
         # start with layer manager on top
         if self.currentPage:
         if self.currentPage:
             self.GetMapDisplay().Raise()
             self.GetMapDisplay().Raise()
@@ -708,6 +715,13 @@ class GMFrame(wx.Frame):
                     return False
                     return False
         return True
         return True
 
 
+    def OnCopyToClipboard(self, event):
+        """Copy selected text in shell to the clipboard"""
+        try:
+            wx.Window.FindFocus().Copy()
+        except:
+            pass
+
     def _switchPageHandler(self, event, notification):
     def _switchPageHandler(self, event, notification):
         self._switchPage(notification=notification)
         self._switchPage(notification=notification)
         event.Skip()
         event.Skip()

+ 15 - 0
gui/wxpython/modules/import_export.py

@@ -21,6 +21,7 @@ This program is free software under the GNU General Public License
 """
 """
 
 
 import os
 import os
+import sys
 
 
 import wx
 import wx
 from core import globalvar
 from core import globalvar
@@ -137,6 +138,13 @@ class ImportDialog(wx.Dialog):
 
 
         self.createSettingsPage()
         self.createSettingsPage()
 
 
+        # Enable copying to clipboard with cmd+c from dialog on macOS
+        # (default key binding will close the dialog), trac #3592
+        if sys.platform == "darwin":
+            self.Bind(wx.EVT_MENU, self.OnCopyToClipboard, id=wx.ID_COPY)
+            self.accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL, ord("C"), wx.ID_COPY)])
+            self.SetAcceleratorTable(self.accel_tbl)
+
     def createSettingsPage(self):
     def createSettingsPage(self):
 
 
         self._blackList = {
         self._blackList = {
@@ -310,6 +318,13 @@ class ImportDialog(wx.Dialog):
         """Do what has to be done after importing"""
         """Do what has to be done after importing"""
         pass
         pass
 
 
+    def OnCopyToClipboard(self, event):
+        """Copy selected text in dialog to the clipboard"""
+        try:
+            wx.Window.FindFocus().Copy()
+        except:
+            pass
+
     def _getLayersToReprojetion(self, projMatch_idx, grassName_idx):
     def _getLayersToReprojetion(self, projMatch_idx, grassName_idx):
         """If there are layers with different projection from loation projection,
         """If there are layers with different projection from loation projection,
            show dialog to user to explicitly select layers which will be reprojected..."""
            show dialog to user to explicitly select layers which will be reprojected..."""