MaskedEditControl bugfix pach from Will Sadkin
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26891 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
186545a42f
commit
89f9e172e2
@ -86,7 +86,7 @@
|
|||||||
provides a single "unified" interface for masked controls. Those for
|
provides a single "unified" interface for masked controls. Those for
|
||||||
masked.TextCtrl, masked.ComboBox and masked.IpAddrCtrl are all documented
|
masked.TextCtrl, masked.ComboBox and masked.IpAddrCtrl are all documented
|
||||||
below; the others have their own demo pages and interface descriptions.
|
below; the others have their own demo pages and interface descriptions.
|
||||||
(See end of following discussion for how to configure the wxMaskedCtrl()
|
(See end of following discussion for how to configure the wx.MaskedCtrl()
|
||||||
to select the above control types.)
|
to select the above control types.)
|
||||||
|
|
||||||
|
|
||||||
@ -528,7 +528,7 @@ Naming Conventions
|
|||||||
the function for getting the start and end of the
|
the function for getting the start and end of the
|
||||||
current text selection. The reason for this is
|
current text selection. The reason for this is
|
||||||
that not all controls have the same function name for
|
that not all controls have the same function name for
|
||||||
doing this; eg. wxTextCtrl uses .GetSelection(),
|
doing this; eg. wx.TextCtrl uses .GetSelection(),
|
||||||
whereas we had to write a .GetMark() function for
|
whereas we had to write a .GetMark() function for
|
||||||
wxComboBox, because .GetSelection() for the control
|
wxComboBox, because .GetSelection() for the control
|
||||||
gets the currently selected list item from the combo
|
gets the currently selected list item from the combo
|
||||||
@ -1581,7 +1581,7 @@ class Field:
|
|||||||
class MaskedEditMixin:
|
class MaskedEditMixin:
|
||||||
"""
|
"""
|
||||||
This class allows us to abstract the masked edit functionality that could
|
This class allows us to abstract the masked edit functionality that could
|
||||||
be associated with any text entry control. (eg. wxTextCtrl, wxComboBox, etc.)
|
be associated with any text entry control. (eg. wx.TextCtrl, wx.ComboBox, etc.)
|
||||||
"""
|
"""
|
||||||
valid_ctrl_params = {
|
valid_ctrl_params = {
|
||||||
'mask': 'XXXXXXXXXXXXX', ## mask string for formatting this control
|
'mask': 'XXXXXXXXXXXXX', ## mask string for formatting this control
|
||||||
@ -2684,10 +2684,11 @@ class MaskedEditMixin:
|
|||||||
## dbg(indent=0)
|
## dbg(indent=0)
|
||||||
return bValid
|
return bValid
|
||||||
|
|
||||||
##! WS: For some inexplicable reason, every wxTextCtrl.SetValue
|
##! WS: For some inexplicable reason, every wx.TextCtrl.SetValue
|
||||||
## call is generating two (2) EVT_TEXT events.
|
## call is generating two (2) EVT_TEXT events. On certain platforms,
|
||||||
|
## (eg. linux/GTK) the 1st is an empty string value.
|
||||||
## This is the only mechanism I can find to mask this problem:
|
## This is the only mechanism I can find to mask this problem:
|
||||||
if newvalue == self._curValue:
|
if newvalue == self._curValue or len(newvalue) == 0:
|
||||||
## dbg('ignoring bogus text change event', indent=0)
|
## dbg('ignoring bogus text change event', indent=0)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -4890,7 +4891,7 @@ class MaskedEditMixin:
|
|||||||
"""
|
"""
|
||||||
This event handler is currently necessary to work around new default
|
This event handler is currently necessary to work around new default
|
||||||
behavior as of wxPython2.3.3;
|
behavior as of wxPython2.3.3;
|
||||||
The TAB key auto selects the entire contents of the wxTextCtrl *after*
|
The TAB key auto selects the entire contents of the wx.TextCtrl *after*
|
||||||
the EVT_SET_FOCUS event occurs; therefore we can't query/adjust the selection
|
the EVT_SET_FOCUS event occurs; therefore we can't query/adjust the selection
|
||||||
*here*, because it hasn't happened yet. So to prevent this behavior, and
|
*here*, because it hasn't happened yet. So to prevent this behavior, and
|
||||||
preserve the correct selection when the focus event is not due to tab,
|
preserve the correct selection when the focus event is not due to tab,
|
||||||
@ -4999,7 +5000,7 @@ class MaskedEditMixin:
|
|||||||
if self._isFloat and groupcharpos > self._decimalpos:
|
if self._isFloat and groupcharpos > self._decimalpos:
|
||||||
# 1st one found on right-hand side is past decimal point
|
# 1st one found on right-hand side is past decimal point
|
||||||
## dbg('groupchar in fraction; illegal')
|
## dbg('groupchar in fraction; illegal')
|
||||||
valid = False
|
return False
|
||||||
elif self._isFloat:
|
elif self._isFloat:
|
||||||
integer = value[:self._decimalpos].strip()
|
integer = value[:self._decimalpos].strip()
|
||||||
else:
|
else:
|
||||||
@ -5153,7 +5154,7 @@ class MaskedEditMixin:
|
|||||||
|
|
||||||
The trouble is that, a priori, there's no explicit notification of
|
The trouble is that, a priori, there's no explicit notification of
|
||||||
why the focus event we received. However, the whole reason we need to
|
why the focus event we received. However, the whole reason we need to
|
||||||
do this is because the default behavior on TAB traveral in a wxTextCtrl is
|
do this is because the default behavior on TAB traveral in a wx.TextCtrl is
|
||||||
now to select the entire contents of the window, something we don't want.
|
now to select the entire contents of the window, something we don't want.
|
||||||
So we can *now* test the selection range, and if it's "the whole text"
|
So we can *now* test the selection range, and if it's "the whole text"
|
||||||
we can assume the cause, change the insertion point to the start of
|
we can assume the cause, change the insertion point to the start of
|
||||||
@ -5258,11 +5259,11 @@ class MaskedEditMixin:
|
|||||||
## dbg('current value: "%s"' % value)
|
## dbg('current value: "%s"' % value)
|
||||||
sel_start, sel_to = self._GetSelection() ## check for a range of selected text
|
sel_start, sel_to = self._GetSelection() ## check for a range of selected text
|
||||||
## dbg('selected text: "%s"' % value[sel_start:sel_to].strip())
|
## dbg('selected text: "%s"' % value[sel_start:sel_to].strip())
|
||||||
do = wxTextDataObject()
|
do = wx.TextDataObject()
|
||||||
do.SetText(value[sel_start:sel_to].strip())
|
do.SetText(value[sel_start:sel_to].strip())
|
||||||
wxTheClipboard.Open()
|
wx.TheClipboard.Open()
|
||||||
wxTheClipboard.SetData(do)
|
wx.TheClipboard.SetData(do)
|
||||||
wxTheClipboard.Close()
|
wx.TheClipboard.Close()
|
||||||
|
|
||||||
if sel_to - sel_start != 0:
|
if sel_to - sel_start != 0:
|
||||||
self._OnErase()
|
self._OnErase()
|
||||||
@ -5274,27 +5275,27 @@ class MaskedEditMixin:
|
|||||||
#
|
#
|
||||||
## def _Copy( self ):
|
## def _Copy( self ):
|
||||||
## """
|
## """
|
||||||
## Override the wxTextCtrl's .Copy function, with our own
|
## Override the wx.TextCtrl's .Copy function, with our own
|
||||||
## that does validation. Need to strip trailing spaces.
|
## that does validation. Need to strip trailing spaces.
|
||||||
## """
|
## """
|
||||||
## sel_start, sel_to = self._GetSelection()
|
## sel_start, sel_to = self._GetSelection()
|
||||||
## select_len = sel_to - sel_start
|
## select_len = sel_to - sel_start
|
||||||
## textval = wxTextCtrl._GetValue(self)
|
## textval = wx.TextCtrl._GetValue(self)
|
||||||
##
|
##
|
||||||
## do = wxTextDataObject()
|
## do = wx.TextDataObject()
|
||||||
## do.SetText(textval[sel_start:sel_to].strip())
|
## do.SetText(textval[sel_start:sel_to].strip())
|
||||||
## wxTheClipboard.Open()
|
## wx.TheClipboard.Open()
|
||||||
## wxTheClipboard.SetData(do)
|
## wx.TheClipboard.SetData(do)
|
||||||
## wxTheClipboard.Close()
|
## wx.TheClipboard.Close()
|
||||||
|
|
||||||
|
|
||||||
def _getClipboardContents( self ):
|
def _getClipboardContents( self ):
|
||||||
""" Subroutine for getting the current contents of the clipboard.
|
""" Subroutine for getting the current contents of the clipboard.
|
||||||
"""
|
"""
|
||||||
do = wxTextDataObject()
|
do = wx.TextDataObject()
|
||||||
wxTheClipboard.Open()
|
wx.TheClipboard.Open()
|
||||||
success = wxTheClipboard.GetData(do)
|
success = wx.TheClipboard.GetData(do)
|
||||||
wxTheClipboard.Close()
|
wx.TheClipboard.Close()
|
||||||
|
|
||||||
if not success:
|
if not success:
|
||||||
return None
|
return None
|
||||||
@ -6352,7 +6353,7 @@ i=1
|
|||||||
## non-british spellings still supported for backward-compatibility.
|
## non-british spellings still supported for backward-compatibility.
|
||||||
## 20. Added '&' mask specification character for punctuation only (no letters
|
## 20. Added '&' mask specification character for punctuation only (no letters
|
||||||
## or digits).
|
## or digits).
|
||||||
## 21. Added (in a separate file) wxMaskedCtrl() factory function to provide
|
## 21. Added (in a separate file) wx.MaskedCtrl() factory function to provide
|
||||||
## unified interface to the masked edit subclasses.
|
## unified interface to the masked edit subclasses.
|
||||||
##
|
##
|
||||||
##
|
##
|
||||||
@ -6376,7 +6377,7 @@ i=1
|
|||||||
## 2. Fixed EUDATE* autoformats, fixed IsDateType mask list, and added ability to
|
## 2. Fixed EUDATE* autoformats, fixed IsDateType mask list, and added ability to
|
||||||
## use 3-char months for dates, and EUDATETIME, and EUDATEMILTIME autoformats.
|
## use 3-char months for dates, and EUDATETIME, and EUDATEMILTIME autoformats.
|
||||||
## 3. Made all date autoformats automatically pick implied "datestyle".
|
## 3. Made all date autoformats automatically pick implied "datestyle".
|
||||||
## 4. Added IsModified override, since base wxTextCtrl never reports modified if
|
## 4. Added IsModified override, since base wx.TextCtrl never reports modified if
|
||||||
## .SetValue used to change the value, which is what the masked edit controls
|
## .SetValue used to change the value, which is what the masked edit controls
|
||||||
## use internally.
|
## use internally.
|
||||||
## 5. Fixed bug in date position adjustment on 2 to 4 digit date conversion when
|
## 5. Fixed bug in date position adjustment on 2 to 4 digit date conversion when
|
||||||
|
Loading…
Reference in New Issue
Block a user