How to prevent mouse leave event when hovering over checkbox - c#

I have a form with the panel, which will have some checkboxes for options. I made panel slide in to the form when mouse hovers the edge of it (edge of panel). I made it hide (slide back) when mouse leaves the panel. The problem is that when I point a checkbox in this panel a mouseleave event occures and panel slides back so I cannot check checkbox. Is there any way to prevent mouseleave event when mouse is still over the panel and some checkboxes in it? My idea for know is to make a condition based on mouse pointer position in mouseleave event, but I hope that there is a way to make app treat a checkbox as a part of panel. Did not put any food since it is not problem of it. But can post if needed.

What happens here is that the mouseleave event of the checkbox triggers mouseleave event of the panel due to the event bubbling. You can read more about event bubbling here.
To prevent the event bubbling, attach mouseleave event on the checkboxes and call event.stopPropagation().
Sample code with jQuery:
$("checkboxes_selector").on("mouseleave", function(event){
event.stopPropagation();
});

Related

How turn on auto update content on mouse button scrolling? wpf

I use ScrollViewer. When I scroll the page with the mouse wheel, everything works fine and the ScrollChanged event cause after each scroll. But when I scroll through the contents of the panel by pressing and holding the scroll bar, then ScrollChanged cause only when I release the mouse button. How can I fix this and make it always update the content.
From Pro WPF 4.5 in C#:
Finally, the ButtonBase class adds a ClickMode property, which determines when a button fires its Click event in response to mouse actions. The default value is ClickMode.Release, which means the Click event fires when the mouse is clicked and released. However, you can also choose to fire the Click event when the mouse button is first pressed (ClickMode.Press) or, oddly enough, whenever the mouse moves over the button and pauses there (ClickMode.Hover).

WinForms pass through clicks to controls below another

I have a following form in WinForms as a prototype for a game:
GestureControl is a transparent Control that handles its MouseDown and MouseUp events to allow for swiping gestures. Then there are SquareControls (game pieces) that should be clickable as well.
I'm not sure how to arrange these controls so both
SquareControl will receive Click event
GestureControl will receive MouseDown and MouseUp events
I know I could add a Click Gesture to my GestureControl (when the distance between mouse down and mouse up is not far away), pass it to parent and invoke the same event handler as if the corresponding SquareControl was clicked, but this seems hackish.

WPF Touch up event in Microsoft surface still calls even I dragg my finger out of the area

I am writing an event for a textBox_Touch_up. And I want if user Touch Up on the text box then fire this event but if user dragged his finger somewhere out of the textbox and then touch up then this event should not be called. Is there any other event with which I can do it or I Have to play with it ?
The touch_up Event does not provide similar functionality for Textboxes because Textboxes contain text. So I used a flat button and it works for me as it does not fire the event when i drag my finger out of it.

Display tooltip when mouse movement stop

I have a grid-view with merged cells and rows which look like this.
I am using grid view mouse enter cell and mouse leave cell events to call the tool-tip show and hide methods.
Problem I am having is, since the cells are very closer tooltip get displayed when I moving across the grid. What I am trying to achieve is display the tooltip only when mouse is stop moving.
Is it possible to capture current state of mouse where I can capture mouse is moving or not.
I have looked at the Control.MouseMove Event, but can I find the current state of the mouse using that.
Update
I did try something like this
In MouseMove event of the gridview tooltip.Hide()
In
MouseHoverCell tooltip.Show() but had no luck with it
Thanks
What you need here is to leverage the OnMouseHover and OnMouseMove events.
The OnMouseHover event is fired when the mouse stops moving. So, in your case, you can fire this event when the mouse stops, pick up the containing cell and show your tooltip. When the OnMouseMove event fires teardown the tooltip and start again.
I hope this helps.

Container Control is losing focus

I'm trying to create User Control which will work like a rich button.
It's supposed to have an effect on hover - I turn border on on MouseEnter and off again at MouseLeave.
BUT, when I hover over label in my control, it fires Control.MouseLeave.
Is there any way to prevent this?
First, focus Enter and Leave are different events than MouseEnter and MouseLeave. Focus deals with keyboard input. MouseEnter and MouseLeave deals with where the mouse is right now.
Entering a nested control fires MouseLeave on the parent control. You can capture the mouse by setting the control's Capture property to true, but you may find that doesn't behave like you'd expect.
You might look at my post here. I had the same issue with nested controls. I opted to create a .NET equivalent of a mouse hook by calling Application.AddMessageFilter.
Another option would be to remove the inner label control and draw the text manually it in the button's OnPaint.

Categories