GNU Emacs Lisp Reference Manual
Sometimes it is useful to track the mouse, which means to display something to indicate where the mouse is and move the indicator as the mouse moves. For efficient mouse tracking, you need a way to wait until the mouse actually moves.
The convenient way to track the mouse is to ask for events to represent mouse motion. Then you can wait for motion by waiting for an event. In addition, you can easily handle any other sorts of events that may occur. That is useful, because normally you don't want to track the mouse forever---only until some other event, such as the release of a button.
read-event or
read-key-sequence. See Motion Events, for the format of mouse
motion events.
The value of track-mouse is that of the last form in body.
The usual purpose of tracking mouse motion is to indicate on the screen the consequences of pushing or releasing a button at the current position.
In many cases, you can avoid the need to track the mouse by using
the mouse-face text property (see Special Properties).
That works at a much lower level and runs more smoothly than
Lisp-level mouse tracking.