Ilia Kats wrote:
Is there any way to get the insertion point in the wxComboBox
when the user writes something in it, like in wxTextCtrl
(wxTextCtrl.GetInsertion() point)? Maybe something similar?
What's wrong with wxComboBox.GetInsertionPoint() ?
(works for me...
Getting the text *selection,* now THAT's an issue... (as there is no
method for it retrieving it yet.) I've filed a bug report on
that, but so far, no one has signed up to fix it. However,
if you need to do this too, I wrote a hack for the soon-to-be
released wxMaskedComboBox to find out what it is (albeit one
generating up to 2 intermediate and EVT_COMBOBOX events -- it uses
Cut(), and examines the difference between the before and after
to tell if anything was selected.) Here's that code:
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 up to 2 intermediate
EVT_COMBOBOX events.
"""
sel_start = sel_to = self.GetInsertionPoint()
value = self.GetValue()
wxComboBox.Cut(self)
newvalue = self.GetValue()
if newvalue != value: # something was selected
wxComboBox.SetValue(self, value) # restore original value
sel_to = sel_start + len(value) - len(newvalue)
wxComboBox.SetMark(self, sel_start, sel_to) # restore selection
return sel_start, sel_to
/Will Sadkin
Parlance Corporation