Page 1 of 1

Mouse Events Issue

Posted: Sun Apr 12, 2020 8:02 pm
by sam_des

I am Writing a custom control & need to detect Mouse events. Been doing testing with wxFormBuilder to generate skeleton of my program while custom control is completely written independently.

Here is the object 2 object trees of skeleton from wxFormBuilder,



This is the code for mouse event connections, wxHistWidget is my custom control derived from wxPanel, for both

Code: Select all

    Connect( wxEVT_MOTION, (wxObjectEventFunction)&wxHistWidget::OnMouseMove );
    Connect( wxEVT_LEFT_DOWN, (wxObjectEventFunction)&wxHistWidget::OnMouseLDownClick );
    Connect( wxEVT_MOUSEWHEEL, (wxObjectEventFunction)&wxHistWidget::OnMouseWheel );
Why the code works in 1 case while not in another?


Re: Mouse Events Issue

Posted: Sun Apr 12, 2020 8:43 pm
by doublemax
The sizer structure shouldn't make any difference for the mouse events. I can't spot any obvious mistake, i can only give the general hints that:
a) mouse events don't propagate upwards in the window hierarchy, so only the item directly under the mouse pointer will receive the mouse event
b) in addition to a) only the item that has focus receives mouse wheel events

Can you show the whole code for wxHistWidget?

Re: Mouse Events Issue

Posted: Mon Apr 13, 2020 3:56 pm
Also, please don't forget to call "event.Skip()", unless you know what you are doing.
And just a suggestion - try to use "Bind()" instead of "Connect()".

Thank you.