Capture mouse events from childwindows
Capture mouse events from childwindows
I added an left button event to my frame window, but since it is covered with the child windows, I never receive such an event. Is there some way to get mouse events regardless of the window? Or do I have to bind to all childwindows?
Re: Capture mouse events from childwindows
Hi,
Mouse events are not propagated up the chain.
You need to catch it at the highest level and send it yourself down the road.
What do you want it to be caught in the window and not the children level?
Thank you.
Mouse events are not propagated up the chain.
You need to catch it at the highest level and send it yourself down the road.
What do you want it to be caught in the window and not the children level?
Thank you.
Re: Capture mouse events from childwindows
That depends on what you want to do. In most cases you probably want wxWindow::CaptureMouse()
https://docs.wxwidgets.org/trunk/classw ... 7ec85fcfef
If that's not sufficient for your task, you have to bind to all descendants, or filter the event at wxApp level.
https://docs.wxwidgets.org/trunk/classw ... ilter.html
Use the source, Luke!
Re: Capture mouse events from childwindows
I have seen that CaptureMouse method, but I'm not sure if this is the proper way to go. I would have to permanently keep the mouse captured, to receive all the events, but then, are they propagated to the correct windows, if I don't need them?doublemax wrote: ↑Fri Apr 09, 2021 3:57 pm That depends on what you want to do. In most cases you probably want wxWindow::CaptureMouse()
https://docs.wxwidgets.org/trunk/classw ... 7ec85fcfef
I'm working on that docking code, and for this I need to monitor mouse events. To find the current window I have to capture the mouse buttons, but according to the docs, the even will only be sent if the mouse is clicked in the client area of that window. So if the childwindow has i.E. a textctrl, then I wont see that mouseclick when it is entered there.
And if I understand that ClientArea constraint right, then I also wouldn't see a mouse click if it happens on the border, right?
I'll also check the AUI code, to see how this is handled there, but I don't want to draw decoration myself or similar. I would like to keep that as small as possible.
I didn't know I can filter at the app level, I definitely will look into this as well. Thanks for that hint!doublemax wrote: ↑Fri Apr 09, 2021 3:57 pm If that's not sufficient for your task, you have to bind to all descendants, or filter the event at wxApp level.
https://docs.wxwidgets.org/trunk/classw ... ilter.html
Re: Capture mouse events from childwindows
At first I tried to bind to the child, but this becomes quite tedious, because I would have to keep track of all child windows and bind there as well. Attaching to wxApp solved my problem clean and nicely!
Re: Capture mouse events from childwindows
I can't say I understand what are you trying to do but FWIW, binding events from all child windows is pretty easy.
For example, see BindEnterAndLeaveWindow() method here: viewtopic.php?f=1&t=44771#p185127
For example, see BindEnterAndLeaveWindow() method here: viewtopic.php?f=1&t=44771#p185127