Input such as mouse and keyboard actions are injected into the Visualize event thread in the same way that other events are. Thus, handling input is a similar process to handling other types of events. Before reading any further, you should be aware that it is possible to handle input events using operators, which are covered at this link.
For this example, we'll demonstrate how to handle a mouse event. Visualize intercepts and injects all mouse events from the operating system into the event thread, including mouse motion and dragging. As previously discussed, the first step to handling any event is to create an event handler class. This is accomplished by subclassing EventHandler and overriding the Handle method so that it performs your custom logic. In this example, we'll simply get the location of the mouse event. Visualize abstracts mouse events into LocatorEvent objects. A locator event could represent an event from a traditional mouse or a touch-screen input event:
Lastly, you need to ensure your event handler is subscribed to the appropriate EventDispatcher. In Visualize, there are two event dispatchers - one from the Database which dispatches events such as errors and warnings, and one from the window which dispatches input events. In this case, we'll use the window event dispatcher.
NOTE: Make sure you retain a reference to your event handler object! If it goes out of scope, it won't work.
The code in the above example assumes there was only one locator in the event, which is usually fine for an application using a conventional mouse. In a touch-screen application, there could by more than one locator returned if the user is touching the screen at more than one location. In that case, you should process each locator separately by examining the locatorEvent.Locators structure. In C++, that structure is an STL vector, and in C# it is a simple array of Locator objects.