Lecture Set 13 Drawing Mouse and Keyboard Events Part B – Mouse and Keyboard Events.
-
Upload
bernard-richard -
Category
Documents
-
view
219 -
download
0
Transcript of Lecture Set 13 Drawing Mouse and Keyboard Events Part B – Mouse and Keyboard Events.
Lecture Set 13
DrawingMouse and Keyboard EventsPart B – Mouse and Keyboard
Events
Slide 2
Objectives
Create event handlers for mouse events Determining the position of the mouse Determining which mouse button was clicked Learning when events, such as MouseClick, MouseDown, MouseEnter, MouseHover, and MouseMove fire
Create event handlers for keyboard events Determining which keyboard button was clicked Learning when events, such as KeyUp, KeyDown,
and KeyPress fire Learn about keyboard properties such as KeyChar, KeyData, and KeyCode and KeyValue
Slide 3
Add more material on mouse events
THIS SLIDE SET NOT YET COMPLETE Get material from Ch 13 of Ekedahl
original version of text Get material on keyboard events from
Dietel, pp 513ff
Slide 4
Introduction to Mouse Events
The MouseClick event fires when the end user clicks the mouse on a form
The MouseDown and MouseUp events fire when the end user presses and releases the mouse, respectively
The MouseEnter and MouseLeave events fire as the mouse enters and leaves a control instance
The MouseMove event fires whenever the end user moves the mouse
Slide 5
Determining Mouse Information
In graphical applications, it is necessary to get the position of the mouse to determine where to draw a shape
It is often necessary to determine which mouse button was clicked
The state of modifier keys (Ctrl, Alt, Shift) must also be determined
It is often necessary to determine whether the mouse wheel was scrolled
Slide 6
The MouseEventArgs Class
The MouseEventArgs class is used to get information about the mouse Use the Button property to determine
which mouse button was clicked Use the X and Y properties to determine
the position of the mouse Use the Delta property to determine the
number of detents the mouse wheel was scrolled