Presentation is loading. Please wait.

Presentation is loading. Please wait.

Keyboards, Pages & Transforms

Similar presentations


Presentation on theme: "Keyboards, Pages & Transforms"— Presentation transcript:

1 Keyboards, Pages & Transforms
By Yi-Yang Huang & Jayashree Venkatesh

2 Ignoring the keyboard Microsoft windows and windows forms class handle many keyboard functions themselves. Ignore keystrokes in menu selection. Windows forms programs define keyboard accelerators to invoke common menu items. Dialog boxes also have a keyboard interface, but programs need not monitor the keyboard when a dialog box is active.

3 Who’s got the focus? A particular keystroke has only a single destination, which is of type Control or a descendant of Control, such as Form. Active form is usually the topmost form on the desktop. Active form is available from the only static property implemented by Form. Type : Form Property : ActiveForm Accessibility : get

4 Form Methods (selection) void Activate() Form Events (selection)
Event Method Delegate Argument Activated OnActivated EventHandler EventArgs Deactivate OnDeactivate EventHandler EventArgs

5 Keyboards and Characters
Keyboard can be A collection of distinct physical keys A means of generating character codes (Unicode). Four groups of keys Toggle keys (Caps, Num, Scroll locks, Insert) Shift keys (Shift, Ctrl, Alt) Noncharacter keys (function, pause, del) Character keys (letter,no,Tab,Backspace,Enter,Esc)

6 Keys Down and Keys Up Control Events (selection)
Event Method Delegate Argument KeyDown OnKeyDown KeyEventHandler KeyEventArgs KeyUp OnKeyUp KeyEventHandler KeyEventArgs protected override void OnKeyDown (KeyEventArgs kea) { }

7 protected override void OnKeyUp (KeyEventArgs kea)
{ } Void MyKeyDownHandler (object objSender, KeyEventsArgs kea) Void MyKeyUpHandler (object objSender, KeyEventsArgs kea)

8 cntl.KeyDown += new KeyEventHandler (MyKeyDownHandler);
cntl.KeyUp += new KeyEventHandler (MyKeyUpHandler); KeyEventArgs Properties Type Property Accessibility Keys KeyCode get Keys Modifiers get Keys KeyData get Bool Shift get Bool Control get Bool Alt get Bool Handled get/set Int KeyValue get

9 Keys Enumeration Keys has 26 members Keys Enumeration (letters)
A – 65 , B – 66 , ….., Z – 90 Keys Enumeration(numbers) D0 – 48, D1 – 49 ….D Keys Enumeration (function keys) F1 – 112, F2 – 113….F24 – 135.

10 Keys Enumeration (keypad operators)
Multiply – 106, Add – 107, Subtract – 109, Divide – 111 Also of Keys Enumeration are the foll: Keypad unused - Separator Keypad cursor movement – Home, Left, End, Insert, Up, Clear, Down, Right, Pageup / Pagedown, Right, Delete ASCII control keys – Back, Tab, Linefeed, Enter Return, Escape, Space Shift keys – Shift, Control , Menu, LShiftkey, Lcontrolkey, LMenu, RShiftkey, RControlkey,RMenu

11 Microsoft keys – LWin, RWin, Apps
Miscellaneous – Cancel, Pause, Capslock, Printscreen, Numlock, Scroll Mouse buttons – LButton, RButton, MButton Special keys – Select, Print, Execute, Help, Processkey, Attn, Play, Zoom Symbols – Oemsemicolon, Oemplus, Oemcomma, Oemminus, Oemperiod, OemQuestion, Oemtilde, OemPipe, Oemquotes, Oembackslash

12 Browsers and players – browserback, browserforward, browserrefresh, browserstop,…., volumemute, volumedown, volumeup,..,launchapplication1,…,mediastop,… IME (Input method editor) – Finalmode, Kanjamode, IMEconvert,IMEaccept…. Modifier keys – none,shift,control, alt Eg: Shift followed by D Masks are provided for differentiating the keycodes and modifiers.

13 Testing the modifier keys
State of modifier keys can also be obtained using the static Control.ModifierKeys property. Keys keysmod =Control.ModifierKeys If (keysMod == (Keys.Shift | Keys.Control)) { // Shift and Ctrl and pressed } If (keysMod == Keys.Shift) { // Shift is pressed } If (keysMod == Keys.Control)) { // Ctrl is pressed }

14 Reality check Problems with Capslock
KeyDown is mostly used for cursor movement, Insert and Delete KeyPress for Characters Control Events(selection) Event Method Delegate Argument KeyPress OnKeyPress KeyPressEventHandler KeyPressEventArgs

15 KeyPressEventArgs Properties
Type Property Accessibility char KeyChar get bool Handled get/set Control Characters Keyboard-Generated Control Characters Key Control Character Shift x0000 Backspace x0008 …….

16 Platform Invocation Services ScrollWindow:
Invoking the Win32 API Platform Invocation Services ScrollWindow: Bool Scrollwindow(HWND hwnd, int Xamount, int Yamount, const RECT * lprect.CONST RECT * lpclipRECT); Typedef struct tagRECT { Long left; Long top; Long right; Long bottom; }RECT;

17 Handling input from foreign keyboards
Control panel – regional options – general tab – change the language settings – reboot Input focus Determines which control gets keyboard input. Control Properties (selection) Type Property Accessibility bool CanFocus get bool ContainsFocus get Bool Focused get

18 Control Methods (selection)
Bool Focus ( ) Control Events(selection) Event Method Delegate Argument GotFocus OnGotFocus EventHandler EventArgs The Missing Caret Cursor is instead referred in Windows as a caret. Caret caret = new Caret (form);

19 Caret Properties Type Property Accessibility Control Control get Size Size get/set Point Position get/set Bool Visibility get/set size of Caret : Caret.Size = new Size( 2, Font.height); Caret Methods : Void Hide(); Void Show(); Void Dispose();

20 protected override void OnGotFocus (EventArgs ea)
{ Base.OnGotFocus(ea); } protected override void OnLostFocus (EventArgs ea) Base.OnLostFocus(ea);


Download ppt "Keyboards, Pages & Transforms"

Similar presentations


Ads by Google