Catching global mouse click 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
Laurent22300
Knows some wx things
Knows some wx things
Posts: 30
Joined: Sun Sep 07, 2008 9:38 am
Contact:

Catching global mouse click

Post by Laurent22300 » Sun Nov 23, 2008 4:11 pm

Hello,

I'm making a custom popup menu using wxWidgets, and one problem I'm running into is that I need to catch global mouse clicks. i.e. when the menu is open, it has to close if the user clicks anywhere (even on another application, or the desktop for example). So basically I need a way to catch a click event at the system level.

I've searched the forum and help file but couldn't find anything. Is it possible to implement in wxWidgets?

Laurent

User avatar
doublemax
Moderator
Moderator
Posts: 15283
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Sun Nov 23, 2008 4:41 pm

did you derive from wxPopupWindow? I've never used it myself but based on the name it should provide the behavior you need.

Apart from that, with wxWindow::CaptureMouse() you should receive all mouse events.

Edit: wxPopupTransientWindow is probably the one you need. Check the "popup" sample.
Use the source, Luke!

Laurent22300
Knows some wx things
Knows some wx things
Posts: 30
Joined: Sun Sep 07, 2008 9:38 am
Contact:

Post by Laurent22300 » Sun Nov 23, 2008 4:47 pm

As usual, many thanks for the quick answer. I didn't know about wxPopupWindow and that CaptureMouse could be use for that, so I'm going to take a look at it.

Post Reply