grd/iup — pull request #4 by philippe-quesnel (2013-08-18 17:41:54+00:00)
Title: added SetIdleFunc().

Hi, I added SetIdleFunc() to permit using the idle loop. Very useful in Go since often goroutines would need to interact with the GUI.

Note that "IDLE_ACTION can only be set using IupSetFunction(name, func)." (IUP doc).
http://www.tecgraf.puc-rio.br/iup/en/call/iup_idle_action.html
So this one can not use IupSetCallback, since it does not have any Ihandle.

The user idle callback function can use a select on input channels and a time.After() to process external events without taking too much CPU (idle loop can behave almost like an infinite loop otherwise)
func idleFunc() int {
select {
case cmd := <-idleChan:
// process cmd
case <-time.After(time.Duration(150 * time.Millisecond)):
}
return iup.DEFAULT
}