Hi again,
I am trying to find the column in a wx.ListCtrl (report mode, obviously)
to provide the right context menu to the user. There is
wx.ListCtrl.HitTestSubItem which should do this according to this
thread: http://markmail.org/message/pd5mlozlvlemy7n4
The documentation
http://www.wxpython.org/docs/api/wx.ListCtrl-class.html#HitTestSubItem
is a bit unclear, as it is the only place where subitems are mentioned
in comparison to columns. Apart from that, the wrapped HitTest method
does not compute the column, it is marked as a TODO here:
http://trac.wxwidgets.org/browser/wxWidgets/branches/WX_2_8_BRANCH/src/generic/listctrl.cpp?rev=63218#L5570
This is why I always get some kind of random number for the column value
in the tuple. I ended up using the code from the mailing list discussion
above, but it turned out that this does not work in all cases: With
scrolling, computing the column manually is off by the amount scrolled.
I ended up accounting for the scrollbar position, by calling
GetScrollPos and GetScrollPixelsPerUnit on the MainWindow of the list
control (see attached code). These should be implementation details of
the ListCtrl, therefore I dislike this approach. Is there a more
official way to find out the column from a mouse event?
Thanks, Torsten
demo_list.py (1.81 KB)
···
--
DYNAmore Gesellschaft fuer Ingenieurdienstleistungen mbH
Torsten Landschoff
Office Dresden
Tel: +49-(0)351-4519587
Fax: +49-(0)351-4519561
mailto:torsten.landschoff@dynamore.de
http://www.dynamore.de
Registration court: Mannheim, HRB: 109659, based in Karlsruhe,
Managing director: Prof. Dr. K. Schweizerhof, Dipl.-Math. U. Franz