#28 wxTreeList Hit test is not working proper


Thanks for bug solving first , I have done same thing in my code and got the scroll event but i got another problem.

When we i first used the code i found that HitTest was not working fine and did not return anything.

1. First i change the code in treeListctrl.cpp file at this place

wxTreeItemId wxTreeListCtrl::HitTest(const wxPoint& pos, int& flags, int& column)
wxPoint p = (pos);
return m_main_win->HitTest (p, flags, column);

It works for me and give me the correct result and i have coding that when i clicked on button it collapse/or expand the button and select the clicked item.

2. Second changes i have done that i implement

void wxTreeListMainWindow::OnScroll (wxScrollWinEvent& event) {
#if defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
HandleOnScroll( event );
if (m_owner->GetEventHandler()->ProcessEvent(event)) return; // handled (and not skipped) in user code


To get the scroll event

3. I have implement the functions to syncronized the scroll position of first window to second window

void wxTreeListMainWindow::SetVScrollPosition(int pos, int orientation)
if(orientation == wxVERTICAL)
Scroll(0, pos);
Scroll(pos, 0);

void wxTreeListCtrl::SetVScrollPosition(int pos, int orientation)
{ m_main_win->SetVScrollPosition(pos, orientation); }

Problem :

Current working:
I am using two treelistctrl to compare directory. I have maintain a map of treeItemId to make synchronization of scrolling and collapsing and expanding item, When i clicked(on mouse click) on first frame it return me treeItemId and on the basis of ItemId , second treelistCtrl correspondence treeItem id get selected , collapsed or expand with help of that map.
HitTest do not retun me the exact TreeItem Id in first frame and after collapsed item it retun me the wrong tree item Id and make selection of different item other then i clicked.

For example i filled 20 item in treelist and last item has 4 child and currently in expanded state, i clicked on button to collapse them , it collapse and select the item one/two upper the item i got selected. I am selecting Item on mouse up event as :

void CUCTreeCtrlEx:: OnLeftMouseUP(wxMouseEvent &event)
int flag;
wxTreeItemId id = HitTest(event.GetPosition(), flag);

CUCTreeCtrlEx is derived with treelistctrl.

Second time its working fine but when i scroll the window and try again to click on button it again return me wrong item id.

I think there is some refreshing problem, please find the attachment as screen Shot.
My treeList is single seleted and os is Linux Ubunto-9.0


  • Ronan Chartois

    Ronan Chartois - 2010-10-24
    • assigned_to: nobody --> pgriddev
  • Ronan Chartois

    Ronan Chartois - 2010-10-24

    once I have had a closer look this ticket will be closed and if applicable tickets in the bug tracker will be opened for OnScroll() and HitTest()

  • Ronan Chartois

    Ronan Chartois - 2011-09-26

    Okay, I am trying to answer point by point:

    1. HitTest() is now fixed, thank you for the report and the fix!
    (the sample program shows the output of HitTest() when middle-clicking)

    2. scroll events are passed to child classes since release 1104 (your other ticket #3082693)

    3. To get the item associated with a collapse/expand, you should use the corresponding event
    (generally speaking, HitTest() is only required to create new events or implement map- or draw- related functionality)
    This being said HitTest() does return the proper item, as far as I can see

    Sorry that it took me so long to get back to you. I hope the latest SVN code works for you, otherwise do not hesitate to let me know

  • Ronan Chartois

    Ronan Chartois - 2011-09-26
    • status: open --> pending-fixed

Log in to post a comment.