There seems to be a small problem with having to poll to find the position of the mouse. For example, if I want to drag something (see file attached), then the object doesn't move together with the mouse.
My suggestion is to have a mousemoved(x, y) callback to allow the application to deal with this event as it happens. In most cases the callback will not be implemented, but sometimes it can be quite useful.
Of course, I can draw the cursor myself, but that's not always the best solution (in a windowed application the user might expect to see the standard cursor).
Suggestion: mousemoved() callback
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Suggestion: mousemoved() callback
- Attachments
-
- drag.love
- (400 Bytes) Downloaded 233 times
Re: Suggestion: mousemoved() callback
I'm not entirely certain what your problem is? The example works perfectly for me with no noticeable lag or anything. I click the square and drag it and the cursor remains and the square is dragged around. WFM.
"Any sufficiently advanced technology is indistinguishable from magic." - Arthur C. Clarke
Re: Suggestion: mousemoved() callback
I must have a slow computer (or graphics card)... didn't think that was the case, it was great when I bought it...
I can certainly see a lag - if I grab the rectangle by the corner and then move it in that direction (the corner's direction) the mouse is outside the rectangle most of the time.
In any case, for a fast computer it won't make a difference if mousemoved() was implemented (the performance hit would be minimal, especially if it's not actually used), whereas for a slow computer it would be very useful.
I'm wondering if I'm the only one with this problem, though...
I can certainly see a lag - if I grab the rectangle by the corner and then move it in that direction (the corner's direction) the mouse is outside the rectangle most of the time.
In any case, for a fast computer it won't make a difference if mousemoved() was implemented (the performance hit would be minimal, especially if it's not actually used), whereas for a slow computer it would be very useful.
I'm wondering if I'm the only one with this problem, though...
Re: Suggestion: mousemoved() callback
This breaks the "drag from the original click point" portion of the code, but purely for testing purposes see if this doesn't help:
Code: Select all
function update(dt)
if drag.active then
local x, y = love.mouse.getPosition()
rect.x = x - drag.dx * dt
rect.y = y - drag.dy * dt
end
end
"Any sufficiently advanced technology is indistinguishable from magic." - Arthur C. Clarke
Re: Suggestion: mousemoved() callback
Thanks for the suggestion. Unfortunately it doesn't help - the cursor is still outside the rectangle most of the time.
I guess for now I'll have to draw the cursor myself - not a big deal, but maybe something to think about for the next version of LÖVE.
I guess for now I'll have to draw the cursor myself - not a big deal, but maybe something to think about for the next version of LÖVE.
Re: Suggestion: mousemoved() callback
The lag is probably due to vertical sync, which can be disabled by setting vsync = false in game.conf. (Unless you've specified "always sync" in your graphics driver settings). Adding mousemoved() will not solve this problem, since events aren't processed while waiting for vertical sync.
Future solutions may involve multi-threading, or setting the actual mouse cursor itself.
Future solutions may involve multi-threading, or setting the actual mouse cursor itself.
Re: Suggestion: mousemoved() callback
Thank you very much! It solved the problem immediately...
Now I'm happy again
Now I'm happy again
Who is online
Users browsing this forum: Ahrefs [Bot] and 1 guest