Chapter 14. Advanced event handling and event busses

 

This chapter covers

  • Creating user-defined events
  • Browser-agnostic handling of events
  • Previewing events and stopping their propagation
  • Using event busses

Our first topic in the advanced part of this book is a deeper look at events and event busses.

Before we get to event busses, we’ll reaffirm the brief description from chapter 3 of what events are and then look at how GWT handles the differences between Internet Explorer and standards-compliant browsers in event handling. This is useful because it means we only have to worry about handling events in one way and not how, say, Firefox handles them compared to IE.

We’ll also show how to preview events so you know what event has been raised before any item gets to handle it. Previewing events means you can cancel them if you want, so that they don’t get handled, or you can use the preview to implement keyboard shortcuts in your application. In addition to previewing events, we’ll also look at preventing the browser from doing its default action—for example, if you drag an image to the location bar it will load only that image, which you might not want to happen.

14.1. Understanding events

14.2. How GWT manages events

14.3. Previewing and canceling events

14.4. Preventing default actions

14.5. Programmatically firing events

14.6. Creating your own events

14.7. Event busses

14.8. Summary