The OpenD Programming Language

BlockingMode

Blocking mode for event loop calls associated with a window instance.

Values

ValueMeaning
automatic0x00

The event loop call will block until the whole application is ready to quit if it is the only one running, but if it is nested inside another one, it will only block until the window you're calling it on closes.

untilApplicationQuits0x01

The event loop call will only return when the whole application is ready to quit. This usually means all windows have been closed.

This is appropriate for your main application event loop.

untilWindowCloses0x02

The event loop will return when the window you're calling it on closes. If there are other windows still open, they may be destroyed unless you have another event loop running later.

This might be appropriate for a modal dialog box loop. Remember that other windows are still processing input though, so you can end up with a lengthy call stack if this happens in a loop, similar to a recursive function (well, it literally is a recursive function, just not an obvious looking one).

onlyIfNotNested0x10

If an event loop is already running, this call will immediately return, allowing the existing loop to handle it. If not, this call will block until the condition you bitwise-or into the flag.

The default is to block until the application quits, same as with the automatic setting (since if it were nested, which triggers until window closes in automatic, this flag would instead not block at all), but if you used BlockingMode.onlyIfNotNested | BlockingMode.untilWindowCloses, it will only nest until the window closes. You might want that if you are going to open two windows simultaneously and want closing just one of them to trigger the event loop return.

Meta

History

Added December 8, 2021 (dub v10.5). Prior to that, all calls to window.eventLoop were the same as calls to EventLoop.get.run; that is, all would block until the application quit.

That behavior can still be achieved here with untilApplicationQuits, or explicitly calling the top-level EventLoop.get.run function.