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
This commit is contained in:
Patrick K. O'Brien
2003-05-04 18:03:17 +00:00
parent f09eff9aea
commit 2383b8d3fe

View File

@@ -182,14 +182,18 @@ class EditWindow(stc.StyledTextCtrl):
else: else:
self.BraceHighlight(braceAtCaret, braceOpposite) self.BraceHighlight(braceAtCaret, braceOpposite)
def CanCut(self):
"""Return true if text is selected and can be cut."""
return self.CanCopy()
def CanCopy(self): 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() 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): def CanEdit(self):
"""Return true if editing should succeed.""" """Return True if editing should succeed."""
return True return not self.GetReadOnly()
def CanPaste(self):
"""Return True if pasting should succeed."""
return stc.StyledTextCtrl.CanPaste(self) and self.CanEdit()