Detecting mouse motion

The MMouseEventHandler class provides a mechanism for tracking continuous mouse motions. Gestures often consist of a click and a drag of the mouse pointer. Use the MMouseEventHandler::StartMouseMovedEvents method if you want to track continuous mouse movement. If your application is already watching a mouse, calling StartMouseMovedEvents will change the focus of the object to watch the new TMouseInputDevice object.

NOTE Override the MouseMoved member function when you want to take an action as the mouse is moved--such as updating the display to reflect the new position.

When you have finished with watching mouse motion, call the MMouseEventHandler::StopMouseMovedEvents method. Remember that Views can only get move events for events that occur within the bounds of the View or sub-View.

Detecting entry and exit to a view

The MMouseEventHandler provides mechanisms to manage the mouse events generated by the entry to and exit from a View. MMouseEventHandler implements:

NOTE Do not depend on the coordinates returned by the methods for Enter and Exit events. The result is nondeterministic.

Views can only get entry and exit events for areas within the bounds of the View. A View can only "watch" itself or a sub-View. It cannot watch a sibling View.

TInteractor objects bypass this restriction--they can watch any view within their thread. Refer to Chapter 4, "View System concepts" for an explanation of Views, threads and TInteractor objects. Refer to "Interactors" on page 34 for an explanation of how the TInteractor mechanism works.

In general, you should structure your application to set the coordinate view to the View that your application wants to watch. Then call the StartMouseEntryEvents method and override the MouseEntered and MouseExited member functions to provide application-specific behavior.

NOTE If you are creating your own views, there is no need to add the mixin class MMouseEventHandler. This is done by the view class.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker