Program windows

An OPENRNDR program can listen to events generated by its window.

Window properties

Window title

The window title can be set and read using the title property.

import org.openrndr.application
import org.openrndr.math.IntVector2

fun main() = application {
    configure {
        title = "Lo and behold!"
    }

    program {
        println(window.title)
    }
}

Window position

The window position can be read and set using the position property.

import org.openrndr.application
import org.openrndr.math.IntVector2

fun main() = application {
    configure {
        position = IntVector2(30, 30)
    }
}

Window events

Window move event

This event is generated when the window was moved.

import org.openrndr.application
import org.openrndr.math.IntVector2

fun main() = application {
    program {
        window.moved.listen {
            println("the window was moved")
        }
    }
}

Window size event

This event is generated when the window was sized.

import org.openrndr.application
import org.openrndr.math.IntVector2

fun main() = application {
    program {
        window.sized.listen {
            println("the window was sized")
        }
    }
}

Window focus event

This event is generated when the program window gains focus.

import org.openrndr.application
import org.openrndr.math.IntVector2

fun main() = application {
    program {
        window.focused.listen {
            println("the window has gained focus")
        }
    }
}

Window unfocus event

This event is generated when the program window loses focus.

import org.openrndr.application
import org.openrndr.math.IntVector2

fun main() = application {
    program {
        window.unfocused.listen {
            println("the window has lost its focus")
        }
    }
}

edit on GitHub