Low-level Event Handling

The most common way for an application to handle events is to call IlvMainLoop after the application is initialized. IlvMainLoop is simply an infinite loop that gets the next incoming event and dispatches it to the appropriate component. However, some applications may need to define their own event loop. To do this, Views provides the following functions or methods:

Main Loop Definition: An Example

Here is a list of constructions that are equivalent to IlvMainLoop:

while (1)

display->waitAndDispatchEvents();

 

while (1)

IlvEventLoop::getEventLoop()->processInput(IlvInputAll);

Windows platforms only:

MSG msg;

while (IlvEventLoop::getEventLoop()->nextEvent(&msg))

IlvEventLoop::getEventLoop()->dispatchEvent(&msg);

 

MSG msg; // obsolete version

while (IlvNextEvent(&msg))

IlvDispatchEvent(&msg);

UNIX platforms only:

XEvent xev;

while (1) {

IlvEventLoop::getEventLoop()->nextEvent(&xev);

IlvEventLoop::getEventLoop()->dispatchEvent(&xev);

}

 

XEvent xev; // obsolete version

while (1) {

IlvNextEvent(&xev);

IlvDispatchEvent(&xev);

}

UNIX platforms using only libmviews (as opposed to libxviews):

XtAppMainLoop(IlvApplicationContext());

 

XEvent xev;

while (1) {

XtAppNextEvent(IlvApplicationContext(), &xev);

XtDispatchEvent(&xev);

}