Mouse Events Issue

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.
Post Reply
sam_des
Earned a small fee
Earned a small fee
Posts: 18
Joined: Wed Aug 30, 2017 4:55 am

Mouse Events Issue

Post by sam_des »

Hello,

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,

Image

Image


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?

Thanks
sam
Attachments
This is one is Working
This is one is Working
working.png (8.08 KiB) Viewed 10582 times
This is not working
This is not working
not_working.png (18.32 KiB) Viewed 10582 times
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Mouse Events Issue

Post 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?
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Mouse Events Issue

Post by ONEEYEMAN »

Hi,
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.
Post Reply