- Fixed masked.numctrl to properly limit integer controls, and
also handle '-.00' properly.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40851
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
Should return False to skip other processing. """
## dbg("MaskedEditMixin::_OnCtrl_V", indent=1)
self.Paste()
Should return False to skip other processing. """
## dbg("MaskedEditMixin::_OnCtrl_V", indent=1)
self.Paste()
return False
def _OnInsert(self, event=None):
return False
def _OnInsert(self, event=None):
## dbg('calling base BaseMaskedTextCtrl._SetValue(self, "%s")' % value)
BaseMaskedTextCtrl._SetValue(self, value)
self.Refresh()
## dbg('calling base BaseMaskedTextCtrl._SetValue(self, "%s")' % value)
BaseMaskedTextCtrl._SetValue(self, value)
self.Refresh()
return
elif self._min > 0 and self.IsLimited():
replacement = self._min
return
elif self._min > 0 and self.IsLimited():
replacement = self._min
## dbg('integer: "%s"' % int)
try:
## dbg('integer: "%s"' % int)
try:
+ # if a float value, this will implicitly verify against limits,
+ # and generate an exception if out-of-bounds and limited
+ # if not a float, it will just return 0.0, and we therefore
+ # have to test against the limits explicitly after testing
+ # special cases for handling -0 and empty controls...
fracval = self.GetFraction(value)
except ValueError, e:
## dbg('Exception:', e, 'must be out of bounds; disallow value')
fracval = self.GetFraction(value)
except ValueError, e:
## dbg('Exception:', e, 'must be out of bounds; disallow value')
+ if fracval == 0.0: # (can be 0 for floats as well as integers)
+ # we have to do special testing to account for emptying controls, or -0
+ # and/or just leaving the sign character or changing the sign,
+ # so we can do appropriate things to the value of the control,
+ # we can't just immediately test to see if the value is valid
+ # If all of these special cases are not in play, THEN we can do
+ # a limits check and see if the value is otherwise ok...
+
## dbg('self._isNeg?', self._isNeg)
if int == '-' and self._oldvalue < 0 and not self._typedSign:
## dbg('just a negative sign; old value < 0; setting replacement of 0')
replacement = 0
self._isNeg = False
## dbg('self._isNeg?', self._isNeg)
if int == '-' and self._oldvalue < 0 and not self._typedSign:
## dbg('just a negative sign; old value < 0; setting replacement of 0')
replacement = 0
self._isNeg = False
- elif int[:2] == '-0' and self._fractionWidth == 0:
if self._oldvalue < 0:
## dbg('-0; setting replacement of 0')
replacement = 0
if self._oldvalue < 0:
## dbg('-0; setting replacement of 0')
replacement = 0
- elif int == '-' and (self._oldvalue >= 0 or self._typedSign) and self._fractionWidth == 0:
+ elif int == '-' and (self._oldvalue >= 0 or self._typedSign):
if not self._limited or (self._min < -1 and self._max >= -1):
## dbg('just a negative sign; setting replacement of -1')
replacement = -1
if not self._limited or (self._min < -1 and self._max >= -1):
## dbg('just a negative sign; setting replacement of -1')
replacement = -1
- if int[0] == '0' and len(int) > 1:
-## dbg('numvalue: "%s"' % numvalue.replace(' ', ''))
+## dbg('numvalue: "%s"' % numvalue.replace(' ', ''))
+ # finally, (potentially re) verify that numvalue will pass any limits imposed:
+ try:
if self._fractionWidth:
value = self._toGUI(string.atof(numvalue))
else:
value = self._toGUI(string.atol(numvalue))
if self._fractionWidth:
value = self._toGUI(string.atof(numvalue))
else:
value = self._toGUI(string.atol(numvalue))
+ except ValueError, e:
+## dbg('Exception:', e, 'must be out of bounds; disallow value')
+ self._disallowValue()
+## dbg(indent=0)
+ return
+
## dbg('modified value: "%s"' % value)
## dbg('modified value: "%s"' % value)
self._typedSign = False # reset state var
if replacement is not None:
self._typedSign = False # reset state var
if replacement is not None: