From 2383b8d3fe9a79848c0a8a918a5d4efe4d84878b Mon Sep 17 00:00:00 2001 From: "Patrick K. O'Brien" Date: Sun, 4 May 2003 18:03:17 +0000 Subject: [PATCH] Improved ``Can*`` checks in ``EditWindow``, since STC is too lenient, particularly when it is set to read-only but returns True for CanPaste() (seems like an STC bug to me). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20475 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/wxPython/py/editwindow.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/wxPython/wxPython/py/editwindow.py b/wxPython/wxPython/py/editwindow.py index 7e7c4bc8fe..cc62b12488 100644 --- a/wxPython/wxPython/py/editwindow.py +++ b/wxPython/wxPython/py/editwindow.py @@ -182,14 +182,18 @@ class EditWindow(stc.StyledTextCtrl): else: self.BraceHighlight(braceAtCaret, braceOpposite) - def CanCut(self): - """Return true if text is selected and can be cut.""" - return self.CanCopy() - def CanCopy(self): - """Return true if text is selected and can be copied.""" + """Return True if text is selected and can be copied.""" return self.GetSelectionStart() != self.GetSelectionEnd() + def CanCut(self): + """Return True if text is selected and can be cut.""" + return self.CanCopy() and self.CanEdit() + def CanEdit(self): - """Return true if editing should succeed.""" - return True + """Return True if editing should succeed.""" + return not self.GetReadOnly() + + def CanPaste(self): + """Return True if pasting should succeed.""" + return stc.StyledTextCtrl.CanPaste(self) and self.CanEdit()