Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix copy-to-clipboard key binding for console (trac#3008) #393

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions gui/wxpython/lmgr/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ def show_menu_errors(messages):

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
if self.currentPage:
self.GetMapDisplay().Raise()
Expand Down Expand Up @@ -693,6 +700,13 @@ def OnCBPageClosed(self, event):

event.Skip()

def OnCopyToClipboard(self, event):
"""Copy selected text in shell to the clipboard"""
try:
wx.Window.FindFocus().Copy()
except:
pass

def _switchPageHandler(self, event, notification):
self._switchPage(notification=notification)
event.Skip()
Expand Down
15 changes: 15 additions & 0 deletions gui/wxpython/modules/import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"""

import os
import sys

import wx
from core import globalvar
Expand Down Expand Up @@ -137,6 +138,13 @@ def __init__(self, parent, giface, itype,

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):

self._blackList = {
Expand Down Expand Up @@ -310,6 +318,13 @@ def OnCmdDone(self, event):
"""Do what has to be done after importing"""
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):
"""If there are layers with different projection from loation projection,
show dialog to user to explicitly select layers which will be reprojected..."""
Expand Down