Chapter 9. jQuery UI mouse interactions
This chapter covers
- The jQuery UI Mouse module
- Creating a jQuery UI plugin that uses the mouse
The last chapter introduced you to the jQuery UI widget framework and walked you through developing a plugin using its abilities. You saw how the framework provides basic management of the widget and helps to keep jQuery UI components consistent in appearance and behavior. Another important part of a web UI is its interaction with the mouse, and standard jQuery supports this through its numerous mouse event handlers. But these handlers operate at the most basic level, leaving more complex interactions for your own development.
jQuery UI makes use of mouse drag operations in several of its widgets and has developed a separate module to deal with these interactions in an easy-to-use and consistent manner. The jQuery UI Mouse module watches the underlying mouse events and converts these into drag events you can react to. It’s similar to your car speedometer, which transforms the individual wheel rotations into an overall speed for you.
To see the Mouse module in action, you’ll develop a plugin that lets you capture a signature drawn with the mouse within a web page and convert it into a text representation for further processing. Additional functionality will allow you to check that a signature has been entered (perhaps for validation purposes), clear a signature, and redisplay it at a later time.