Predefined IUP action, generated when there are no events or messages to be processed. Often used to perform background operations.


int function(void); [in C]

Returns: if IUP_CLOSE is returned the current loop will be closed and the callback will be removed. If IUP_IGNORE is returned the callback is removed and normal processing continues.


The Idle callback will be called whenever there are no messages left to be processed. But this occurs more frequent than expected, for example if you move the mouse over the application the idle callback will be called many times because the mouse move message is processed so fast that the Idle will be called before another mouse move message is schedule to processing.

So this callback changes the message loop to a more CPU consuming one. It is important that you set it to NULL when not using it. Or the application will be consuming CPU even if the callback is doing nothing.

It can only be set using IupSetFunction(name, func).

Lua Binding 

To modify this action use the function iup.SetIdle(func) in Lua. Using nil as a parameter to remove the association.

Or use the iup.SetGlobalCallback(name, func) function. (since 3.7)

Long Time Operations

If you create a loop or an operation that takes a long time to complete inside a callback of your application then the user interface message loop processing is interrupted until the callback returns, so the user can not click on any control of the application. But there are ways to handle that:

If you just want to do something simple as a background redraw of an IupCanvas, then a better idea is to handle the "idle" state yourself. For example, register a timer for a small time like 500ms, and reset the timer in all the mouse and keyboard callbacks of the IupCanvas. If the timer is trigged then you are in idle state. If the IupCanvas loses its focus then stop the timer.


Browse for Example Files

See Also

IupSetFunction, IupTimer.