Double-clicking on a row in an ObjectListView

Hi,

This should be easy, but as usual, I'm confused.

What I'm trying to do is capture a double-click on an output list displayed from a database using an ObjectListView. The display is no problem. But I can't figure out how to get the doubleclick captured by the ObjectListView Object.

Here is what I hope is sufficient relevant code:

-----------------------------------------------------------------------------------------------------

import wx

from ObjectListView import ObjectListView, ColumnDefn

class Listview(wx.Panel):
    """Constructs a listing of records resulting from user queries, allowing users to
    double-click a row to focus on a specific record"""
    def __init__(self, parent, querystring, querylist, listtype):
        wx.Panel.__init__(self, parent)
        ...
        self.outputview = ObjectListView(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
        ...
        # set the data list for display
        self.outputview.SetColumns(columnlist)
        self.outputview.SetObjects(self.displaylist)
        # Make the list display double clickable
        self.Bind(wx.EVT_LEFT_DCLICK, self.OnSelect, self.outputview)
        # Alternative Bind
        self.Bind(wx.EVT_LEFT_DCLICK, self.OnSelect, self)
    def OnSelect(self, event):
        print "double click detected"

--------------------------------------------------------------------------------------------------------------

Using the alternative Bind I can get OnSelect to work if I doubleclick within the panel but outside the boundaries of the list. But with self.outputview in the Bind line, I don't get the method to ever trigger.

What's the trick? Am I 100 miles off base?

I don't use double click, but instead do:

self.myOlv.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onOLVItemSelected)

Note that I bind to the OLV and not like you to the panel and I don't use the 3rd param to define the OLV, should work for double click too, I think/guess.

BTW, within your handler you will have to ensure that an item is actually selected.

Werner

ยทยทยท

On 24/08/2012 01:32, llanitedave wrote: