wxTreeListCtrl - How to receive mouse events

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
m.a.k.
Earned a small fee
Earned a small fee
Posts: 15
Joined: Fri Jul 04, 2008 8:13 pm

wxTreeListCtrl - How to receive mouse events

Post by m.a.k. »

Hi.

I'm using the wxTreeListCtrl (http://wxcode.sourceforge.net/components/treelistctrl/).

Everything works fine except of one thing: I don't know how to receive simple mouse events with this control...

I just want to receive an event when the user clicks on an item, but when I try to set an event handler with

Code: Select all

m_treelist->Connect(ID_TREELISTCTRL, wxEVT_LEFT_DOWN, wxMouseEventHandler(MainWindow::OnLeftDown), NULL, this);
and I click somewhere on the tree list control it just happens - nothing... ;(

The same for all other mouse events like mouse move, right click etc.

Hope someone could help me with this.

Regards,
m.a.k.
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Hi,

Nobody who knows the answer seems to be going to respond, so...

Without looking at the source I can't be sure, but I suspect that a wxTreeListCtrl is a composite control of a treectrl and a listctrl. An example where I know this is true is wxGenericDirCtrl, which contains a member wxTreeCtrl.

To get events using Connect() from a wxGenericDirCtrl, you can't use a pointer to the wxGenericDirCtrl; you have to get one to the underlying treectrl (using wxGenericDirCtrl::GetTreeCtrl). I suspect you will need to do something similar, Connect()ing to the underlying listctrl.

I suggest you have a look at the source-code.

Regards,

David
AlanC
In need of some credit
In need of some credit
Posts: 1
Joined: Sun Oct 04, 2009 7:00 am
Location: S. California

Post by AlanC »

To receive events it is also necessary to have an EVENT_TABLE or dynamicly connect the event to a function.

example:

BEGIN_EVENT_TABLE(LayoutTreeCtrl, wxTreeCtrl)
EVT_TREE_BEGIN_RDRAG(ID_LAYOUT_TREE, OnBeginRDrag) EVT_TREE_ITEM_ACTIVATED(ID_LAYOUT_TREE,OnSectionSelection)
END_EVENT_TABLE( )
Post Reply