masked/textctrl.py: A code refactoring bugfix for .ChangeValue() support.

masked/combobox.py: Several fixes for value selection behavior, and
                    one for navigation in readonly control.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45968 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2007-05-11 19:48:22 +00:00
parent cf151d7e00
commit d40652f42e
2 changed files with 130 additions and 44 deletions

View File

@@ -176,15 +176,28 @@ class BaseMaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ):
wx.TextCtrl.ChangeValue(self, value)
## dbg(indent=0)
def SetValue(self, value, use_change_value=False):
def SetValue(self, value):
"""
This function redefines the externally accessible .SetValue() to be
a smart "paste" of the text in question, so as not to corrupt the
masked control. NOTE: this must be done in the class derived
from the base wx control.
"""
## dbg('MaskedTextCtrl::SetValue("%(value)s", use_change_value=%(use_change_value)d)' % locals(), indent=1)
self.ModifyValue(value, use_change_value=False)
def ChangeValue(self, value):
"""
Provided to accomodate similar functionality added to base control in wxPython 2.7.1.1.
"""
self.ModifyValue(value, use_change_value=True)
def ModifyValue(self, value, use_change_value=False):
"""
This factored function of common code does the bulk of the work for SetValue
and ChangeValue.
"""
## dbg('MaskedTextCtrl::ModifyValue("%(value)s", use_change_value=%(use_change_value)d)' % locals(), indent=1)
if not self._mask:
if use_change_value:
@@ -214,7 +227,7 @@ class BaseMaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ):
value = value[1:]
## dbg('padded value = "%s"' % value)
# make SetValue behave the same as if you had typed the value in:
# make Set/ChangeValue behave the same as if you had typed the value in:
try:
value, replace_to = self._Paste(value, raise_on_invalid=True, just_return_value=True)
if self._isFloat:
@@ -247,12 +260,6 @@ class BaseMaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ):
wx.CallAfter(self._SetSelection, replace_to, replace_to)
## dbg(indent=0)
def ChangeValue(self, value):
"""
Provided to accomodate similar functionality added to base control in wxPython 2.7.1.1.
"""
self.SetValue(value, use_change_value=True)
def SetFont(self, *args, **kwargs):
""" Set the font, then recalculate control size, if appropriate. """