event triggering madness Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
dsacks
In need of some credit
In need of some credit
Posts: 3
Joined: Wed Aug 06, 2008 9:57 pm

event triggering madness

Post by dsacks »

windows/ c++ / wxwidgets 2.8.?

I have a wxGenericDirCtrl. I am doing a connect on the wxEVT_COMMAND_TREE_SEL_CHANGED event to do some things when the user single clicks on the directory tree. This works.

However I'd also like to expand the node they click on if it is expandable. Unfortunately if I do that when I deal with the above event I go into an endless loop - I think because the dirCtrl->ExpandPath(path) causes another wxEVT_COMMAND_TREE_SEL_CHANGED to be fired. How do I get around this problem?
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

(Moved from wxCode forum, which is intended for discussions of the projects residing at wxCode.)

Hi,

Well, you could use EVT_TREE_ITEM_ACTIVATED instead (that's generated by a double-click).

Alternatively, you could Disconnect() wxEVT_COMMAND_TREE_SEL_CHANGED until things have settled down, then re-Connect() it again.

Regards,

David
dsacks
In need of some credit
In need of some credit
Posts: 3
Joined: Wed Aug 06, 2008 9:57 pm

Post by dsacks »

Thanks for your reply David. I'll try the disconnect idea. I hadn't thought of that.
DavidHart wrote:
Well, you could use EVT_TREE_ITEM_ACTIVATED instead (that's generated by a double-click).

Alternatively, you could Disconnect() wxEVT_COMMAND_TREE_SEL_CHANGED until things have settled down, then re-Connect() it again.

Regards,

David
Post Reply