click and double-click dance?

How I would handle this:

def OnMouseDown(self, evt):
    c = time.time()
    if self.clicktime-c < DOUBLECLICKTIME:
        self.SelectWord(evt)
    else:
        self.SelectSentence(evt)
    self.clicktime = c
    #never .Skip() the event, as we want to handle both single and
    #double clicks here

I would guess that you can acquire the platform-specific time for the

DOUBLECLICKTIME constant, though I haven’t looked into it.

  • Josiah

Hm. You may be right. I was hoping to avoid coding my own SelectWord – but I’ll probably have to anyway, since I want to control what punctuation is included (internal only; hyphens and apostrophes), which the system’s auto-select won’t do.

As for double-click time, that looks kind of tricky. The user expects to be able to set it system wide (at least on OS X). Retrieving that current value, on different platforms, sounds like a mess.

Charles

Here's another try:

Only bind OnMouseDown and OnDoubleClick.

    def OnDoubleClick(self, evt):
        self.handled = 1
        #handle selection of a single word

    def OnMouseDown(self, evt):
        self.handled = 0
        wx.CallAfter(self.OnMouseDown2, evt.GetPosition())
        #if the above doesn't work, try using
        #wx.FutureCall(1, self.OnMouseDown2, evt.GetPosition())
        evt.Skip()

    def OnMouseDown2(self, evt):
        if self.handled:
            return
        #handle selection of the sentence

wx.CallAfter may not do it, however, wx.FutureCall uses a wx.Timer
events to schedule future calls, and wx.Timer events are fired after the
event queue is empty; so OnDoubleClick() will occur before OnMouseDown2
().

- Josiah

···

Charles Hartman <charles.hartman@conncoll.edu> wrote:

Hm. You may be right. I was hoping to avoid coding my own SelectWord
-- but I'll probably have to anyway, since I want to control what
punctuation is included (internal only; hyphens and apostrophes),
which the system's auto-select won't do.

As for double-click time, that looks kind of tricky. The user expects
to be able to set it system wide (at least on OS X). Retrieving that
current value, on different platforms, sounds like a mess.

Charles Hartman wrote:

As for double-click time, that looks kind of tricky. The user expects to be able to set it system wide (at least on OS X). Retrieving that current value, on different platforms, sounds like a mess.

I thought we had a function that would return this value, but I can't seem to find it now. I guess I was thinking of something else. So this would make a good feature request for wxWidgets.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!