wxListBox and EVT_RIGHT_UP

Kelvin Lawson wrote:

Hi,

Is there a proper way to handle right-clicking items in a listbox? I'd like to find out which item the mouse is over when the right button is clicked.

I've done this by getting the x/y mouse position and using GetCharHeight() to calculate which item is selected - see the code below. But this seems to be platform-dependent. It works here (Gnome) but not on other systems I've tried (KDE and Windows).

Does anyone know if there is a correct way of doing this?

It currently can't be done (without guessing anyway) using wx.ListBox. You can however use a wx.ListCtrl with wx.LC_REPORT and wx.LC_NOHEADER styles and it will look/act much like a wx.ListBox, and it has a HitTest method that will let you know exactly which item the mouse is over.

ยทยทยท

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

It currently can't be done (without guessing anyway) using wx.ListBox. You can however use a wx.ListCtrl with wx.LC_REPORT and wx.LC_NOHEADER styles and it will look/act much like a wx.ListBox, and it has a HitTest method that will let you know exactly which item the mouse is over.

Thanks, I've gone with a listctrl and they offer far more features than listboxes.

Kelvin.