I'm making a dinky paint program where the paint color cycles through the rainbow, and I was wondering if there was any way to know if the user's mouse has left the window. It isn't in the best interest of the program to have a square of color cycling at the edge of my window, and I'd like to pause the color cycle when the mouse leaves the window. love.mouse.getX/Y only go to the length of the window. It would be nice if they returned nil if the mouse was offscreen, but oh well. Is there any way to get around this?
Also, to clarify, I'm not talking about the window being unfocused.
Thanks
How to know if the mouse is offscreen?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: How to know if the mouse is offscreen?
Maybe you can try to get X, Y and if X or Y is less than 0 or more than love.graphics.getWidth/Height() then it's offset. I hadn't tried but maybe this works. Or you can try X,Y equal to 0, or equal to love.graphics.getWidth/getHeight() (-1). The second will work.Djent wrote:I'm making a dinky paint program where the paint color cycles through the rainbow, and I was wondering if there was any way to know if the user's mouse has left the window. It isn't in the best interest of the program to have a square of color cycling at the edge of my window, and I'd like to pause the color cycle when the mouse leaves the window. love.mouse.getX/Y only go to the length of the window. It would be nice if they returned nil if the mouse was offscreen, but oh well. Is there any way to get around this?
Also, to clarify, I'm not talking about the window being unfocused.
Thanks
- xXxMoNkEyMaNxXx
- Party member
- Posts: 206
- Joined: Thu Jan 10, 2013 6:16 am
- Location: Canada
Re: How to know if the mouse is offscreen?
Does it have something to do with focus lost?
I saw that the mouse never returns values outside of the screen.
I saw that the mouse never returns values outside of the screen.
Re: How to know if the mouse is offscreen?
Bitbucket discussion about this, with my dumb answer at the end
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: How to know if the mouse is offscreen?
Or for a simpler solution, but maybe less comfortable for the end-user:
love.mouse.setGrab( true )
love.mouse.setGrab( true )
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 99 guests