MouseEntryEvents

MouseEntryEvents is a sample that illustrates how to use MouseEntered and MouseExited, together with StartMouseEntryEvents, to find out when the mouse enters and exits a view. Because of the overhead, mouse entry and exit events are not reported automatically for all MMouseEventHandlers.

Running the sample

Execute MouseEntryEventsSApp. Double-click any mouse button in one of the views to toggle entry/exit reporting. As the mouse moves in and out of the views, the views report this. Click Close to quit.

Files and classes

TMouseInputView is defined in MouseInputView.h and MouseInputView.C. It is basically the same as the version in MouseEventsInViews, except that 1) It calls SetCoordinateView after registering with the event receiver, to indicate the view for which entry and exit reports should be reported, and 2) it calls StartMouseEntryEvents and StopMouseEntryEvents in response to a double-click in MouseButtonDown. It also overrides MouseEntered and MouseExited to report when these events are received.

Notes

The order in which MouseEntered and MouseExited are called is not guaranteed. The entering view can have MouseEntered called on it before the exiting view has MouseExited called on it, or vice-versa.

Do not call GetLocation on the event sent with MouseEntered and MouseExited, as the coordinate system for the mouse location is not guaranteed.

If a view has visible subviews, they are considered not part of the parent view, and when the mouse moves over them, MouseExited will be sent to the parent view. There is no way to alter this behavior.

If you call StartMouseEntryEvents while the mouse is already in the target view, no entry event is reported until the mouse moves.

The input system does not yet support multiple mice, so it is not currently possible to have more than one mouse in a view, or for views to track only a particular mouse.

The view under the mouse is asked to handle the event. Regardless of whether it does, or returns true if it does, the event is not passed to ancestor views.


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