I've got an STC subclass with a method to stc.EVT_DOUBLECLICK. (It's also got a wx.EVT_KEY_DOWN - bound method, but I don't see why there would be an interaction problem.) I'll give the code below, with its complications, but the gist is this: after the double-click has selected a word (handled by the STC), when I move the mouse it keeps extending the selection. How do I get it to stop?? Putting an event.Skip() at the end of the method doesn't seem to make any difference. I tried HideSelection(0), but it didn't work either. What am I missing, and what's the right way out? I can't remember whether the same thing happens when I port the app over to Windows.
The "grandma" and "cousin" bits in this code are my brute-force ways of handling the fact that the app has two STCs, and I need to find out who "I" am before I can respond (in quite different ways) to the double-click; and a double-click in either window has effects in the other. (Is there a more orthodox way to do this?)
==== code begins ----------------------------------
def DoubleClick(self, event):
grandma = self.GetParent().GetParent()
if self.FindFocus() == grandma.tSTC: # in text
str = self.GetSelectedText()
result = grandma.addKeyEntry(str)
cuz = grandma.cSTC
if result:
cuz.ScrollToLine(cuz.GetLineCount() + 1)
grandma.displayConc()
else: # in conc's cSTC instead
text, pos = self.GetCurLine()
lnum = int(text[:CONC_LNUMSIZE])
i = lnum
while grandma.tLines[i] != lnum: i += 1
grandma.tSTC.ScrollToLine(i)
------------------------------- code ends =======
I've got an STC subclass with a method to stc.EVT_DOUBLECLICK. (It's
also got a wx.EVT_KEY_DOWN - bound method, but I don't see why there
would be an interaction problem.) I'll give the code below, with its
complications, but the gist is this: after the double-click has
selected a word (handled by the STC), when I move the mouse it keeps
extending the selection. How do I get it to stop?? Putting an
event.Skip() at the end of the method doesn't seem to make any
difference. I tried HideSelection(0), but it didn't work either. What
am I missing, and what's the right way out? I can't remember whether
the same thing happens when I port the app over to Windows.
This is a total guess but try calling ReleaseMouse().
The "grandma" and "cousin" bits in this code are my brute-force ways of
handling the fact that the app has two STCs, and I need to find out who
"I" am before I can respond (in quite different ways) to the
double-click; and a double-click in either window has effects in the
other. (Is there a more orthodox way to do this?)
The best way is to use the "source" param to self.Bind (or ID, for
the EVT_ functions) and bind the controls to totally seperate
handlers.
stc1 = wx.stc.StyledTextControl(parent)
stc2 = wx.stc.StyledTextControl(parent)
self.Bind(wx.EVT_LEFT_DCLICK, self.DoubleClickOne, source=stc1)
self.Bind(wx.EVT_LEFT_DCLICK, self.DoubleClickTwo, source=stc2)
···
On Sat, 23 Oct 2004 19:12:41 -0400, Charles Hartman <cohar@conncoll.edu> wrote:
==== code begins ----------------------------------
def DoubleClick(self, event):
grandma = self.GetParent().GetParent()
if self.FindFocus() == grandma.tSTC: # in text
str = self.GetSelectedText()
result = grandma.addKeyEntry(str)
cuz = grandma.cSTC
if result:
cuz.ScrollToLine(cuz.GetLineCount() + 1)
grandma.displayConc()
else: # in conc's cSTC instead
text, pos = self.GetCurLine()
lnum = int(text[:CONC_LNUMSIZE])
i = lnum
while grandma.tLines[i] != lnum: i += 1
grandma.tSTC.ScrollToLine(i)
------------------------------- code ends =======