1 Lecture 5: Conventional Input Models for Window Managers and Toolkits Brad Myers 05-830 Advanced User Interface Software © 2013 - Brad Myers.

Slides:



Advertisements
Similar presentations
CS7026 jQuery Events. What are Events?  jQuery is tailor-made to respond to events in an HTML page.  Events are actions that can be detected by your.
Advertisements

1 Fac.Scienze – Università di Trento Programmazione 2 - Marco Ronchetti Events Gestione degli eventi.
1 Model View Controller. 2 Outline Review Definitions of MVC Why do we need it? Administiriva Changing the display Event flow Dragging at interactive.
Tutorial 15 Working with the Event Model. XP Objectives Compare the IE and W3C event models Study how events propagate under both event models Write a.
1 Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software.
Graphical User Interface (GUI) Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
0 CS 160: Design Process: Implement Event-based UI Programming, Model-View-Controller, and the Web Jeffrey Nichols IBM Almaden Research Center
Introduction to Computing Dr. Nadeem A Khan. Lecture 13.
Event Handling. In this class we will cover: Keyboard Events Mouse Events Focus Events Action Interface Multicasting.
Object-Oriented Analysis and Design
1 Lecture 5: Window Manager Input Models Brad Myers Advanced User Interface Software.
CSE 331 Software Design & Implementation Dan Grossman Spring 2015 GUI Event-Driven Programming (Based on slides by Mike Ernst, Dan Grossman, David Notkin,
CS0004: Introduction to Programming Events. Review  Event Procedure  A set of instructions to be executed when a certain event happens.  Many event-driven.
A.k.a. GUI’s.  If you want to discuss your Lab 2 grade come see me this week. ◦ Office: 436 ERB. One hour prior to class ◦ Open to Appointments MWF 
Welcome to CIS 083 ! Events CIS 068.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Gary MarsdenSlide 1University of Cape Town Human-Computer Interaction - 3 Programmer Support Gary Marsden ( ) July 2002.
Lecture Set 13 Drawing Mouse and Keyboard Events Part B – Mouse and Keyboard Events.
Java Programming: Guided Learning with Early Objects
Timer, Animation Responding to Mouse & Keyboard Lab 7 7 McGraw-Hill© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Building X Window GUIs with Motif The X Window System: Architecture Applications Sample code Review function (as time permits) … Introduce what it’s like.
1 Chapter Eleven Handling Events. 2 Objectives Learn about delegates How to create composed delegates How to handle events How to use the built-in EventHandler.
Lecture 6: Introduction to Graphical User Interfaces (GUIs)
COM148X1 Interactive Programming Lecture 7. Topics Today HCI Event Handling.
Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software 1© 2013.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
1 Lecture 2: Overview of UI Software and Tools Brad Myers Advanced User Interface Software.
UID – Event Handling and Listeners Boriana Koleva
Interactive Programs Java API. Terminology Event—an action or occurrence, not part of a program, detected by the program. Events can be Event—an action.
CS-1020 Dr. Mark L. Hornick 1 Event-Driven Programming.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Object Oriented Programming.  Interface  Event Handling.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Event-Driven Programming 1.
Index Event Handling Events Event Source Event Listener Event Classes Action Event Class Adjustment event Class Event Source Event Listener Interface Using.
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Copyright © 2007 by Curt Hill Interrupts How the system responds.
1 Why Threads are a Bad Idea (for most purposes) based on a presentation by John Ousterhout Sun Microsystems Laboratories Threads!
Exceptions Lecture 11 COMP 401, Fall /25/2014.
CIS 338: Events Dr. Ralph D. Westfall April, 2011.
Pen Based User Interface Issues CSE 490RA January 25, 2005.
Implement User Input Windows Development Fundamentals LESSON 2.4A.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
Lecture 5: Conventional Input Models for Window Managers and Toolkits
The structure of Interactive Software
Event Loops and GUI Intro2CS – weeks
CompSci 230 S Software Construction
Validating User Input Lesson 5.
Event loops 16-Jun-18.
Chapter Eleven Handling Events.
Lecture 6: Window Manager Input Models
JavaScript and Events.
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Event Driven Programming
Visual Basic Properties, Methods and Events
Introduction to Computing Using Java
Event loops.
Introduction to jQuery
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Event loops 8-Apr-19.
JavaScript and Events CS Programming Languages for Web Applications
Event loops.
Event loops.
Event loops 19-Aug-19.
JavaScript and Events CS Programming Languages for Web Applications
Presentation transcript:

1 Lecture 5: Conventional Input Models for Window Managers and Toolkits Brad Myers Advanced User Interface Software © Brad Myers

2 Quotes “One of the most complex aspects of Xlib programming is designing the event loop, which must take into account all of the possible events that can occur in a window.” -- Nye & O'Reilly X Toolkit Intrinsics Programming Manual, vol. 4, 1990, p “The dispatching and handling of events is rather complicated.” -- Galaxy Reference Manual, v1.2, p © Brad Myers

3 How Keyboard and Mouse Events are Handled Most window manager and toolkits use the same model Quite old and has problems © Brad Myers

First issue: Which Window? Called “focus” Old name: “active” window Click to Type Move to Type Affects what kinds of interactions are possible Mac single menubar not possible with move-to- type © Brad Myers4

5 Event Records Structures (records) composed of all information about events Created by window manager, sent to a queue for each window X defines 33 different types of events Except for selectionRequest, the X/11 “*request” events are only for window managers © Brad Myers

6 X Event Types 1.buttonPress 2.keyPress 3.keyRelease 4.buttonRelease 5.motionNotify 6.enterNotify 7.leaveNotify 8.focusIn 9.focusOut 10.keymapNotify (change keymap) 11.Expose 12.graphicsExpose (source of copy not available) 13.noExpose (source of copy is available) 14.colormapNotify 15.propertyNotify (some property changed) 16.visibilityNotify (become covered) 17.resizeRequest 18.circulateNotify (stacking order) 19.configureNotify (resize or move) 20.destroyNotify (was destroyed) 21.gravityNotify (moved due to gravity) 22.mapNotify (became visible) 23.createNotify 24.reparentNotify (in diff. window) 25.unmapNotify (invisible) 26.circulateRequest 27.configureRequest 28.mapRequest 29.mappingNotify (keyboard mapping) 30.clientMessage 31.selectionClear (for cut and paste) 32.selectionNotify 33.selectionRequest © Brad Myers

Windows.Net 4.5 Events 1. AutoSizeChanged 2. BackColorChanged 3. BackgroundImageChanged 4. BackgroundImageLayoutChanged 5. BindingContextChanged 6. CausesValidationChanged 7. ChangeUICues 8. Click 9. ClientSizeChanged 10. ContextMenuChanged 11. ContextMenuStripChanged 12. ControlAdded 13. ControlRemoved 14. CursorChanged 15. Disposed 16. DockChanged 17. DoubleClick 18. DragDrop 19. DragEnter 20. DragLeave 21. DragOver 22. EnabledChanged 23. Enter 24. FontChanged 25. ForeColorChanged 26. GiveFeedback 27. GotFocus 28. HandleCreated 29. HandleDestroyed 30. HelpRequested 31. ImeModeChanged 32. Invalidated 33. KeyDown 34. KeyPress 35. KeyUp 36. Layout 37. Leave 38. LocationChanged 39. LostFocus 40. MarginChanged 41. MouseCaptureChanged 42. MouseClick 43. MouseDoubleClick 44. MouseDown 45. MouseEnter 46. MouseHover MouseLeave 48. MouseMove 49. MouseUp 50. MouseWheel 51. Move 52. PaddingChanged 53. Paint 54. ParentChanged 55. PreviewKeyDown 56. QueryAccessibilityHelp 57. QueryContinueDrag 58. RegionChanged 59. Resize 60. RightToLeftChanged 61. SizeChanged 62. StyleChanged 63. SystemColorsChanged 64. TabIndexChanged 65. TabStopChanged 66. TextChanged 67. Validated 68. Validating 69. VisibleChanged Source:

8 Other events Java has events for: MouseMove vs. MouseDrag Java event hierarchy starts from java.awt.AWTEventjava.awt.AWTEvent Many special events: PaintEvent, WindowEvent, HierarchyEvent, etc.PaintEventWindowEventHierarchyEvent Java event tutorial Visual Basic has events for: Drag Drop Timer MouseWheel iOS (iPhone): accelerometer; remote controls HTML/CSS supports Hover In X, a window specifically declares which events they want to receive using event masks Reduces network traffic and unnecessary processing Event masks also used for other things in X “pointerGrab” Source: eptual/EventHandlingiPhoneOS/Introduction/Introduction.html eptual/EventHandlingiPhoneOS/Introduction/Introduction.html

Event Modifiers Which “modifier” keys Shift, Control, Alt, Function, Command (Mac), Num-Lock Various combinations Can get events when Shift, etc. goes down, but usually ignored Single click, double-click, triple-click, etc. Click vs. Down vs. Drag Amulet supports string parsing of names: “SHIFT_CONTROL_DOUBLE_LEFT_DOWN” 9© Brad Myers

Gestural “Events” Gestures might come in as if they were regular events So lower-level code doesn’t need to distinguish Android has separate “gesture” classes iOS: Gesture Recognizers Amulet: added at higher level, as “commands” (see next lecture) 10© Brad Myers

11 Event Handling Toolkits (e.g., Visual Basic) automatically handle expose and some other events for the widgets. Structured graphics systems (e.g., Amulet) automatically handle many of the events. Events (in X) are C-language union type of many event structures that are all the same size but with different field names. Key and mouse events contain (at least): 1.x position of the mouse 2.y position of the mouse 3.window of the mouse 4.event type 5.event code 6.event modifiers 7.timestamp © Brad Myers

12 Examples Amulet lowest levels: Big switch statement gemW_draw.cc (see MainWndProc) gemW_draw.cc gemX_input.cc (see Am_Handle_Event_Received) gemX_input.cc Issue: new types of events E.g, tablet eraser on stylus, proximity Gesture, mouse wheel events, like scroll New types of devices: e.g., hardware widgets © Brad Myers

13 Waiting for Events Low-level routine that waits for event wants to be blocking rather than polling for efficiency Calls specified routines when events arrive Macintosh (used to?) use polling for mouse location Toolkits provide this internally, e.g.: XtAppMainLoop(...) Am_Main_Event_Loop() in Amulet Can specify timeouts so notified after certain time if no events Can ask X to flush multiple motion events If not handled fast enough, get weird lag Garnet tries to do extra flushing to avoid this Not an issue if polling for motion events Problem for polylines, gestures, etc. Java listeners for events © Brad Myers

Architectures Old: giant switch statement per window Branch for each event But not dependent on mode, which object, etc. “MainEventLoop” in Amulet’s implementation Global event handlers for each type of event No matter where that event happens in the window E.g., per Activity in Android Specific event handlers per object Java Swing: button1.addActionListener(this); Android: View event listeners (since widgets are views) But only works if knows where the objects are Lots of issues with multiple threading © Brad Myers14

Propagation Events sent to the lowest level window containing the pointer. If event not selected with event-mask, then sent to the container window, etc. Can't specify individual keys (get all keys and may have to explicitly resend events) Handlers often will get to say whether they handled the event or not Android: onXXXX() handlers return booleans © Brad Myers15

Which objects get an event when overlapping “Z” order vs. containment What about when top object doesn’t want event? Can’t necessarily use obj.contains(eventX, eventY) Input mechanism must know about graphical objects Bounding box vs. on object Complexities: ndlingiPhoneOS/event_delivery_responder_chain/event_delivery_responder_chain.html#// apple_ref/doc/uid/TP CH4-SW2 ndlingiPhoneOS/event_delivery_responder_chain/event_delivery_responder_chain.html#// apple_ref/doc/uid/TP CH4-SW2 Issue: Covering 16 © Brad Myers

Issue: Event Priorities When already interacting, need to give priority to current interaction While dragging, who gets mouse move events? Issue: if mouse is moved too fast & gets outside of the object While text editing Current field gets all text events, no matter where mouse is What if leave the window? Interacts with Click vs. move to type Cross-window drag & drop 17 © Brad Myers

18 Translation Tables So particular mouse key or keyboard key not hard-wired into application. Allows user customization and easier changes Supported in Motif by the resources mechanism e.g. Shift : doit() can be put in.Xdefaults, and then application deals with doit, and user can change bindings. Keyboard translation is 2 step process in X: Hardware "keycodes" numbers mapped to "keysyms" "Keysyms" translated to events For double-clicking, Motif does translation, but not Xlib For non-widgets, have to do it yourself Always also get the single click events Java – no built-in double click support Does have click vs. drag © Brad Myers

19 Issue: Scrolling Refresh Race condition when copy from an area that might be covered X/11 provides graphicsExpose and noExpose events © Brad Myers