Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
- Earned a small fee
- Posts: 13
- Joined: Wed Aug 30, 2017 4:55 am
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?
- This is one is Working
- working.png (8.08 KiB) Viewed 234 times
- This is not working
- not_working.png (18.32 KiB) Viewed 234 times
- Posts: 14954
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
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?
Use the source, Luke!
- Part Of The Furniture
- Posts: 4235
- Joined: Sat Apr 16, 2005 7:22 am
- Location: USA, Ukraine
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()".