Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between mouseenter and mousehover?

Tags:

c#

In a C# Windows application there are 2 different mouse events, MouseEnter and MouseHover, which are both triggered when the cursor is over the object.

What is the difference between them?

like image 490
Zahema Avatar asked Dec 15 '14 21:12

Zahema


People also ask

What does Mouseenter function do?

The mouseenter() method is an inbuilt method in jQuery which works when mouse pointer moves over the selected element. Parameters: This method accepts single parameter function which is optional. It is used to specify the function to run when the mouseenter event is called.

What is the difference between Mouseout and Mouseleave?

This means that mouseleave is fired when the pointer has exited the element and all of its descendants, whereas mouseout is fired when the pointer leaves the element or leaves one of the element's descendants (even if the pointer is still within the element).

What is the use of mouseover?

The mouseover event is fired at an Element when a pointing device (such as a mouse or trackpad) is used to move the cursor onto the element or one of its child elements.


1 Answers

Assuming you are in Windows Forms:

Mouse Enter occurs:

Occurs when the mouse pointer enters the control.

(MSDN)

Mouse Hover:

Occurs when the mouse pointer rests on the control.

A typical use of MouseHover is to display a tool tip when the mouse pauses on a control within a specified area around the control (the "hover rectangle"). The pause required for this event to be raised is specified in milliseconds by the MouseHoverTime property.

(MSDN)

To set MouseHoverTime globally (not recommended, see @IronMan84's link here for a better solution), you can use the SystemParametersInfo function. Because thats a Win32 API call, you'll need PInvoke:

[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SystemParametersInfo(SPI uiAction, uint uiParam, IntPtr pvParam, SPIF fWinIni);

Called as:

SystemParametersInfo(SPI.SPI_SETMOUSEHOVERTIME, 
                     desiredHoverTimeInMs, 
                     null, 
                     SPIF.SPIF_SENDCHANGE );

Sigantures from PInvoke.NET: SystemParametersInfo, SPIF (Enum), SPI (Enum)

I didn't include the Enum signatures here because they are so freaking long. Just use the ones on PInvoke.Net (linked above)

For complete information on the SystemParametersInfo API call and its parameters, see MSDN.

like image 149
BradleyDotNET Avatar answered Sep 20 '22 07:09

BradleyDotNET