X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/02b800ce7c2bb1c1f08075f22be2e7412124b47f..1ffc8d7a55af1c253ca363bb0fbdda26bb4c9c65:/wxPython/wx/lib/masked/maskededit.py diff --git a/wxPython/wx/lib/masked/maskededit.py b/wxPython/wx/lib/masked/maskededit.py index d2be65e91d..7127285046 100644 --- a/wxPython/wx/lib/masked/maskededit.py +++ b/wxPython/wx/lib/masked/maskededit.py @@ -831,7 +831,7 @@ nav = ( ) control = ( - wx.WXK_BACK, wx.WXK_DELETE, WXK_CTRL_A, WXK_CTRL_C, WXK_CTRL_S, WXK_CTRL_V, + wx.WXK_BACK, wx.WXK_DELETE, wx.WXK_INSERT, WXK_CTRL_A, WXK_CTRL_C, WXK_CTRL_S, WXK_CTRL_V, WXK_CTRL_X, WXK_CTRL_Z ) @@ -1715,7 +1715,8 @@ class MaskedEditMixin: wx.WXK_NEXT: self._OnAutoCompleteField, # default function control keys and handlers: - wx.WXK_DELETE: self._OnErase, + wx.WXK_DELETE: self._OnDelete, + wx.WXK_INSERT: self._OnInsert, WXK_CTRL_A: self._OnCtrl_A, WXK_CTRL_C: self._OnCtrl_C, WXK_CTRL_S: self._OnCtrl_S, @@ -1991,7 +1992,7 @@ class MaskedEditMixin: width = self.GetSize().width height = self.GetBestSize().height ## dbg('setting client size to:', (width, height)) - self.SetBestFittingSize((width, height)) + self.SetInitialSize((width, height)) # Set value/type-specific formatting self._applyFormatting() @@ -2075,7 +2076,7 @@ class MaskedEditMixin: # the outside size that does include the borders. What you are # calculating (in _CalcSize) is the client size, but the sizers # deal with the full size and so that is the minimum size that - # we need to set with SetBestFittingSize. The root of the problem is + # we need to set with SetInitialSize. The root of the problem is # that in _calcSize the current client size height is returned, # instead of a height based on the current font. So I suggest using # _calcSize to just get the width, and then use GetBestSize to @@ -2083,7 +2084,7 @@ class MaskedEditMixin: self.SetClientSize(self._CalcSize()) width = self.GetSize().width height = self.GetBestSize().height - self.SetBestFittingSize((width, height)) + self.SetInitialSize((width, height)) # Set value/type-specific formatting @@ -3202,6 +3203,32 @@ class MaskedEditMixin: ## dbg(indent=0) return False + def _OnInsert(self, event=None): + """ Handles shift-insert and control-insert operations (paste and copy, respectively)""" +## dbg("MaskedEditMixin::_OnInsert", indent=1) + if event and isinstance(event, wx.KeyEvent): + if event.ShiftDown(): + self.Paste() + elif event.ControlDown(): + self.Copy() + # (else do nothing) + # (else do nothing) +## dbg(indent=0) + return False + + def _OnDelete(self, event=None): + """ Handles shift-delete and delete operations (cut and erase, respectively)""" +## dbg("MaskedEditMixin::_OnDelete", indent=1) + if event and isinstance(event, wx.KeyEvent): + if event.ShiftDown(): + self.Cut() + else: + self._OnErase(event) + else: + self._OnErase(event) +## dbg(indent=0) + return False + def _OnCtrl_Z(self, event=None): """ Handles ctrl-Z keypress in control and Undo operation on context menu. Should return False to skip other processing. """ @@ -6572,6 +6599,10 @@ __i=0 ## CHANGELOG: ## ==================== +## Version 1.10 +## 1. Added handling for WXK_DELETE and WXK_INSERT, such that shift-delete +## cuts, shift-insert pastes, and ctrl-insert copies. +## ## Version 1.9 ## 1. Now ignores kill focus events when being destroyed. ## 2. Added missing call to set insertion point on changing fields.