Yann
February 2, 2020, 2:39am
1
How can I determine when the mouse enters or exits the application window?
For example, in Processing, there are APIs for mouseEntered() and mouseExited()
Thank you.
abe
February 6, 2020, 3:31pm
2
I don’t see such events at Mouse And Keyboard Events - OPENRNDR GUIDE
Related is window-unfocus-behaviour which lets you slow down the frame rate when the window is unfocused. So there must be a way to tap into that information. Maybe @ricardo has an idea?
kazik
February 14, 2020, 2:22pm
3
It seems that the hook is there, but it is not implemented:
val position = if (fixWindowSize) Vector2(xpos, ypos) / program.window.scale else Vector2(xpos, ypos)
logger.trace { "mouse moved $xpos $ypos -- $position" }
realCursorPosition = position
program.mouse.moved.trigger(MouseEvent(position, Vector2.ZERO, Vector2.ZERO, MouseEventType.MOVED, MouseButton.NONE, globalModifiers))
if (down) {
program.mouse.dragged.trigger(MouseEvent(position, Vector2.ZERO, position - lastDragPosition, MouseEventType.DRAGGED, MouseButton.NONE, globalModifiers))
lastDragPosition = position
}
}
glfwSetCursorEnterCallback(window) { window, entered ->
logger.trace { "cursor state changed; inside window ($window) = $entered" }
}
if (configuration.showBeforeSetup) {
logger.debug { "clearing and displaying pre-setup" }
// clear the front buffer
glDepthMask(true)
glClearColor(0.5f, 0.5f, 0.5f, 0.0f)
glClear(GL_COLOR_BUFFER_BIT or GL_STENCIL_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
edwin
March 13, 2020, 12:49pm
4
These events have been added and will be available in the upcoming OPENRNDR 0.3.40 release.
Yann
March 16, 2020, 2:04pm
5
Fantastic! Thank you for adding these.
abe
March 31, 2020, 6:26pm
6
Now it’s available
mouse.entered.listen {
println("mouse in")
}
mouse.left.listen {
println("mouse out")
}