problem with MouseEnter event on a Custom Control

J

Jim

Hi all,

I wrote a simple custom that contains several buttons. Everything went
fine with the control and I am using it on several forms in another project.

The problem occurred when I activated the MouseEnter event (used to be
called onMouseOver?) on the control. I discovered that the MouseEnter event
applies to the custom control's form, but not the buttons within the
control. Several of the buttons are at the edge of the control. If I
moused over my custom control at one of the buttons, then the MouseEnter
event did not fire (because it does not exist for the button). If I moused
over my custom control between buttons, then the MouseEnter event fires
normally.

Is there a way to make the MouseEnter event apply to my entire custom
control? One possibility is to activate the event for every control within
the custom control's container, but this would be very inefficient and I am
concerned about performance. Mouse enter and leave events would be firing
as the mouse was moved over my control.

Thanks,

Jim
 
A

AlexS

Hi, Jim

I would suggest to hook Mouse enter/leave event on buttons too. You can use
same event handler for all controls on your control. And I wouldn't worry
much about performance - it's user interaction, so some small delays are
always acceptable.
Otherwise you might want to check if MouseHover will work for you.

HTH
Alex
 
J

Jim

Can I handle the Click event of a button in my custom control without taking
focus on the button? How do you cancel focus?

Right now I have all the buttons in my control calling the same handler for
MouseEnter with no noticable performance impact. The user interaction is
correct, but I suspect there is a much cleaner/easier solution.

Thanks again,

Jim

P.S. I am iterating a small array of controls in the MouseEnter. I am
trying to find where focus is just prior to any buttons in the custom
contorol being clicked (and receiving focus in the process).
 
A

AlexS

Jim,

I don't think Click event can happen without first focusing the control.
You can remove focus by setting it to another control in the Click.
And you can detect where mouse is using MouseMove/Hover events.
If you put buttons inside control then maybe one MouseEnter of parent
control would do the work.
....don't be too suspicious:)

HTH
Alex
 
J

Jim

Thanks for the replies and the info. I was trying to use the MouseEnter of
the parent, but that doesn't work properly. I think I'll be OK with using
the MouseEnter on each button. Not exactly what I wanted, but the user
won't notice anything.

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top