# o wxTimeCtrl -> TimeCtrl
#
-'''\
+"""\
====================
Masked Edit Overview
====================
Eg::
- formatcodes = ',', groupChar="'" allows 12'345.34
+ formatcodes = ',', groupChar='\'' allows 12'345.34
formatcodes = ',', groupChar='.', decimalChar=',' allows 12.345,34
(These are control-level parameters.)
If not specified as a keyword argument, the default controlType is
controlTypes.TEXT.
-'''
+"""
"""
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
field = self._FindField(pos)
## dbg("key ='%s'" % chr(key))
-## if chr(key) == ' ':
+ if chr(key) == ' ':
## dbg('okSpaces?', field._okSpaces)
-## pass
+ pass
char = chr(key) # (must work if we got this far)
if pos == year2dig and unadjusted[year2dig] != newstr[year2dig]:
newpos = pos+2
+## dbg('queuing insertion point: (%d)' % newpos)
wx.CallAfter(self._SetInsertionPoint, newpos)
if match_field is not None:
else:
newfield = self._FindField(newpos)
if newfield != field and newfield._selectOnFieldEntry:
+## dbg('queuing insertion point: (%d)' % newfield._extent[0])
+ wx.CallAfter(self._SetInsertionPoint, newfield._extent[0])
## dbg('queuing selection: (%d, %d)' % (newfield._extent[0], newfield._extent[1]))
wx.CallAfter(self._SetSelection, newfield._extent[0], newfield._extent[1])
else:
## dbg('match found:', choice)
match = index
break
- else: dbg('choice: "%s" - no match' % choice)
+ else:
+## dbg('choice: "%s" - no match' % choice)
+ pass
if match is not None:
## dbg('matched', match)
pass
# if entire field is selected or position is at end and field is not full,
- # or if allowed to right-insert at any point in field and field is not full and cursor is not at a fillChar:
+ # or if allowed to right-insert at any point in field and field is not full and cursor is not at a fillChar
+ # or the field is a singleton integer field and is currently 0 and we're at the end:
if( (sel_start, sel_to) == field._extent
- or (pos == end and input_len < field_len)):
+ or (pos == end and ((input_len < field_len)
+ or (field_len == 1
+ and input_len == field_len
+ and field._isInt
+ and value[end-1] == '0'
+ )
+ ) ) ):
pos = end - 1
## dbg('pos = end - 1 = ', pos, 'right_insert? 1')
right_insert = True
## dbg("checking appropriate regex's")
value = self._eraseSelection(self._GetValue())
if right_insert:
+ # move the position to the right side of the insertion:
at = pos+1
else:
at = pos
fstr = text[start:end]
erasable_chars = [field._fillChar, ' ']
- if field._padZero:
+ # if zero padding field, or a single digit, and currently a value of 0, allow erasure of 0:
+ if field._padZero or (field._isInt and (end - start == 1) and fstr[0] == '0'):
erasable_chars.append('0')
erased = ''
#### dbg("fstr[0]:'%s'" % fstr[0])
#### dbg('field_index:', field._index)
#### dbg("fstr[0] in erasable_chars?", fstr[0] in erasable_chars)
-#### dbg("self._signOk and field._index == 0 and fstr[0] in ('-','(')?",
-## self._signOk and field._index == 0 and fstr[0] in ('-','('))
+#### dbg("self._signOk and field._index == 0 and fstr[0] in ('-','(')?", self._signOk and field._index == 0 and fstr[0] in ('-','('))
if fstr[0] in erasable_chars or (self._signOk and field._index == 0 and fstr[0] in ('-','(')):
erased = fstr[0]
#### dbg('value: "%s"' % text)
old_right_signpos = text.find(')')
if field._allowInsert and not field._insertRight and sel_to <= end and sel_start >= start:
- # inserting within a left-insert-capable field
+## dbg('inserting within a left-insert-capable field')
field_len = end - start
before = text[start:sel_start]
after = text[sel_to:end].strip()
char = char.decode(self._defaultEncoding)
newtext = left + char + right
+#### dbg('left: "%s"' % left)
+#### dbg('right: "%s"' % right)
+#### dbg('newtext: "%s"' % newtext)
if self._signOk and self._useParens:
# Balance parentheses:
if not valid:
## dbg('cannot convert string to valid time')
pass
- if valid: dbg('valid date')
+## if valid: dbg('valid date')
## dbg(indent=0)
return valid
""" Handler for EVT_KILL_FOCUS event.
"""
## dbg('MaskedEditMixin::_OnKillFocus', 'isDate=',self._isDate, indent=1)
+ if self.IsBeingDeleted() or self.GetParent().IsBeingDeleted():
+ return
if self._mask and self._IsEditable():
self._AdjustField(self._GetInsertionPoint())
self._CheckValid() ## Call valid handler
and sel_to >= edit_end
and not self._GetValue()[edit_start:sel_start].strip() ):
# text won't fit within selection, but left of selection is empty;
- # check to see if we can expand selection to accomodate the value:
+ # check to see if we can expand selection to accommodate the value:
empty_space = sel_start - edit_start
amount_needed = len(paste_text) - (sel_to - sel_start)
if amount_needed <= empty_space: