Foundation > Events > Low-level Event Handling
 
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, Rogue Wave® Views provides the following functions or methods:
*IlvDisplay methods for defining event loops are:
*hasEvents
*readAndDispatchEvents
*waitAndDispatchEvents
*IlvEventLoop methods for defining event loops are:
*pendingInput
*processInput
*nextEvent
*dispatchEvent
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);
}

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.