- def GetMark(self):
- """
- This function is a hack to make up for the fact that wxComboBox has no
- method for returning the selected portion of its edit control. It
- works, but has the nasty side effect of generating lots of intermediate
- events.
- """
-## dbg(suspend=1) # turn off debugging around this function
-## dbg('MaskedComboBox::GetMark', indent=1)
- if self.__readonly:
-## dbg(indent=0)
- return 0, 0 # no selection possible for editing
-## sel_start, sel_to = wxComboBox.GetMark(self) # what I'd *like* to have!
- sel_start = sel_to = self.GetInsertionPoint()
-## dbg("current sel_start:", sel_start)
- value = self.GetValue()
-## dbg('value: "%s"' % value)
-
- self._ignoreChange = True # tell _OnTextChange() to ignore next event (if any)
-
- wx.ComboBox.Cut(self)
- newvalue = self.GetValue()
-## dbg("value after Cut operation:", newvalue)
-
- if newvalue != value: # something was selected; calculate extent
-## dbg("something selected")
- sel_to = sel_start + len(value) - len(newvalue)
- wx.ComboBox.SetValue(self, value) # restore original value and selection (still ignoring change)
- wx.ComboBox.SetInsertionPoint(self, sel_start)
- wx.ComboBox.SetMark(self, sel_start, sel_to)
-
- self._ignoreChange = False # tell _OnTextChange() to pay attn again
-
-## dbg('computed selection:', sel_start, sel_to, indent=0, suspend=0)
- return sel_start, sel_to
+ # Not all wx platform implementations have .GetMark, so we make the following test,
+ # and fall back to our old hack if they don't...
+ #
+ if not hasattr(wx.ComboBox, 'GetMark'):
+ def GetMark(self):
+ """
+ This function is a hack to make up for the fact that wx.ComboBox has no
+ method for returning the selected portion of its edit control. It
+ works, but has the nasty side effect of generating lots of intermediate
+ events.
+ """
+## dbg(suspend=1) # turn off debugging around this function
+## dbg('MaskedComboBox::GetMark', indent=1)
+ if self.__readonly:
+## dbg(indent=0)
+ return 0, 0 # no selection possible for editing
+## sel_start, sel_to = wxComboBox.GetMark(self) # what I'd *like* to have!
+ sel_start = sel_to = self.GetInsertionPoint()
+## dbg("current sel_start:", sel_start)
+ value = self.GetValue()
+## dbg('value: "%s"' % value)
+
+ self._ignoreChange = True # tell _OnTextChange() to ignore next event (if any)
+
+ wx.ComboBox.Cut(self)
+ newvalue = self.GetValue()
+## dbg("value after Cut operation:", newvalue)
+
+ if newvalue != value: # something was selected; calculate extent
+## dbg("something selected")
+ sel_to = sel_start + len(value) - len(newvalue)
+ wx.ComboBox.SetValue(self, value) # restore original value and selection (still ignoring change)
+ wx.ComboBox.SetInsertionPoint(self, sel_start)
+ wx.ComboBox.SetMark(self, sel_start, sel_to)
+
+ self._ignoreChange = False # tell _OnTextChange() to pay attn again
+
+## dbg('computed selection:', sel_start, sel_to, indent=0, suspend=0)
+ return sel_start, sel_to
+ else:
+ def GetMark(self):
+## dbg('MaskedComboBox::GetMark()', indent = 1)
+ ret = wx.ComboBox.GetMark(self)
+## dbg('returned', ret, indent=0)
+ return ret