40 likes | 243 Views
Object passed to event handler. Private: System::Void radio_MouseEnter( Object * sender, EventArg * e) { if ( sender == radioButton1) { // action } if ( sender == radioButton2) { // action } } Register one event handler to more object. Mouse Event Handling.
E N D
Object passed to event handler • Private: System::Void radio_MouseEnter( • Object * sender, EventArg * e) • { • if ( sender == radioButton1) { // action } • if ( sender == radioButton2) { // action } • } • Register one event handler to more object
Mouse Event Handling • Mouse events are generated when the mouse interacts with a control • Mouse event information is passed using class MouseEventArgs • The delegate to create the mouse event handlers is MouseEventHandler • Each mouse event handling method must take an object and a MouseEventArgs as arguments
MouseEventArgs • Class MouseEventArgs contains information about the mouse event, such as the x- and y- coordinates of the mouse pointer, the mouse button pressed, the number of clicks • Button - Mouse button that was pressed(left, right, middle or none) • Clicks - the number of times the mouse button(either) was clicked • X – the x-coordinate of the event • Y – the y-coordinate of the event
Mouse events and delegates Handler • Mouse Events(EventHandler) • MouseEnter – Raised if the mouse cursor enters the area of the control • MouseLeave – Raised if the mouse leaves the area of the control • MouseEvents(MouseEventHandler) • MouseDown – raised if the mouse button is pressed • MouseHover – raised if the mouse hovers over the area of the control • MouseMove – raised if the mouse is moved while in the area of the control • MouseUp – raised if the mouse is released when the cursor is over the area of the control