I want to implement a subclass of ListBox. Once the mouse move on it
(catch the EVT_MOTION event), the item under the mouse is
automatically selected(no need to click the item), and if the selected
text is longer than the width of the listbox, a tooltip will popup to
show the entire string. It will be useful when writing an application
with a sidebar to show log messages.
The first problem I ran into is how to get the item index under the
mouse position. It seems there isn't any mouse-relative methods for
the wxListBox class according to the wxWindows reference. I found
there is a method named "HitTest" by pydoc, however it always returns
10 regardless what mouse position I send to it. So, what
method/function should I use?
I had considered to use wxListCtrl instead, but it will have a header
bar on the top (wx.LC_NO_HEADER only available under Windows) and
cannot hide the horizontal scroll bar.
I want to implement a subclass of ListBox. Once the mouse move on it
(catch the EVT_MOTION event), the item under the mouse is
automatically selected(no need to click the item), and if the selected
text is longer than the width of the listbox, a tooltip will popup to
show the entire string. It will be useful when writing an application
with a sidebar to show log messages.
The first problem I ran into is how to get the item index under the
mouse position. It seems there isn't any mouse-relative methods for
the wxListBox class according to the wxWindows reference. I found
there is a method named "HitTest" by pydoc, however it always returns
10 regardless what mouse position I send to it. So, what
method/function should I use?
ListBox doesn't have a HitTest method. The one you are getting is the generic one from wx.Window.
I had considered to use wxListCtrl instead, but it will have a header
bar on the top (wx.LC_NO_HEADER only available under Windows) and
cannot hide the horizontal scroll bar.
wx.LC_NO_HEADER does work on the other platforms. The horizontal scrollbar can be avoided by ensuring that the column(s) are not wider than the window.
ยทยทยท
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!