![]() |
Mouse Events |
|
Introduction |
|
The mouse is another object that is attached to the computer allowing the user to interact with the machine. The mouse and the keyboard can each accomplish some tasks that are not normally available on the other or both can accomplish some tasks the same way. The mouse is equipped with two, three, or more buttons. When a mouse has two buttons, one is usually located on the left and the other is located on the right. When a mouse has three buttons, one usually is in the middle of the other two. A mouse can also have a round object referred to as a wheel. |
|
The mouse is used to select a point or position on the screen. Once the user has located an item, which could also be an empty space, a letter or a word, he or she would position the mouse pointer on it. To actually use the mouse, the user would press either the left, the middle (if any), or the right button. If the user presses the left button once, this action is called Click. If the user presses the right mouse button, the action is referred to as Right-Click. If the user presses the left button twice and very fast, the action is called Double-Click. If the mouse is equipped with a wheel, the user can position the mouse pointer somewhere on the screen and roll the wheel. This usually causes the document or page to scroll up or down, slow or fast, depending on how it was configured.
Before using a control using the mouse, the user must first position the mouse on it. When this happens, the control fires a MouseEnter event. Its syntax is: Public Event MouseEnter As EventHandler This event is carried by an EventArgs argument but does not provide much information, only to let you know that the mouse was positioned on a control.
Whenever the mouse is being moved on top of a control, a mouse event is sent. This event is called MouseMove and is of type MouseEventArgs. Its syntax is: Public Event MouseMove As MouseEventHandler To implement this event, a MouseEventArgs argument is passed to the MouseEventHandler event implementer: Public Delegate Sub MouseEventHandler ( _ sender As Object, _ e As MouseEventArgs) The MouseEventArgs argument provides the necessary information about the event such as what button was clicked, how many times the button was clicked, and the location of the mouse.
If the user positions the mouse on a control and hovers over it, a MouseHover event is fired: Public Event MouseHover As EventHandler This event is carried by an EventArgs argument that does not provide further information than the mouse is hovering over the control.
Imagine the user has located a position or an item on a document and presses one of the mouse buttons. While the button is pressed and is down, a button-down message is sent. This event is called MouseDown: Public Event MouseDown As MouseEventHandler The MouseDown event is of type MouseEventArgs. Like the other mouse move events, the MouseDown event is carried by a MouseEventArgs argument.
After pressing a mouse button, the user usually releases it. While the button is being released, a button-up message is sent and it depends on the button, left or right, that was down. The event produced is MouseUp: Public Event MouseUp As MouseEventHandler Like the MouseDown message, the MouseUp event is of type MouseEventArgs which is passed to the MouseEventHandler for processing.
When the user moves the mouse pointer away from a control, the control fires a MouseLeave event: Public Event MouseLeave As EventHandler |
|
|
||
| Home | Copyright © 2008 FunctionX, Inc. | Home |
|
|
||