I've got a cursor replacement system in my game, hiding the mouse, then drawing the current cursor image at the mouse's co-ordinates. This works fine, except if the game is not running fullscreen, and the mouse cursor is moved outside the window the image sticks around wherever the cursor exited it. After some testing it appears that getPosition always returns the last spot the mouse was inside the window, and I don't see another way to query if the mouse is outside the window.
Note that I don't want to lock the cursor inside the window, unless the game is being run fullscreen. Is there a way for me to detect when the mouse moves outside the love window so I can stop drawing the cursor?
Thanks
P.S. Love the framework. Keep up the good work.
Detecting if cursor is outside the window
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 34
- Joined: Fri Sep 24, 2010 5:46 am
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Detecting if cursor is outside the window
This is a limit to SDL as far as I can tell, combine that with the fact that we don't expose a mouse-enter and mouse-leave event, it's pretty much impossible, but is it bad?
-
- Prole
- Posts: 34
- Joined: Fri Sep 24, 2010 5:46 am
Re: Detecting if cursor is outside the window
The main point of changing the cursor is for showing what action will be taken if the user clicks on a hex in my hex grid, so I can probably work around if it's not doable, by switching the regular cursor on at any time the mouse isn't over the grid. It would be nice if the cursor could always display special ability icons while special abilities are selected though, to remind the user that it is selected.
Is it hard to expose mouse enter and leave? If it's a bother than working around it isn't a big deal.
Is it hard to expose mouse enter and leave? If it's a bother than working around it isn't a big deal.
- Thursdaybloom
- Citizen
- Posts: 81
- Joined: Mon Feb 15, 2010 3:43 am
- Location: Australia
Re: Detecting if cursor is outside the window
The window dimensions are set in conf.lua so maybe making it only draw the cursor if the mouse is within the dimensions? I can't try that right now however.
Re: Detecting if cursor is outside the window
There should really be an actual way to change the cursor. I hate hiding it and replacing it with an image..
Hello, I am not dead.
- Thursdaybloom
- Citizen
- Posts: 81
- Joined: Mon Feb 15, 2010 3:43 am
- Location: Australia
Re: Detecting if cursor is outside the window
In regards to amount of characters typed to achieve results, how is that better than the current method?
Re: Detecting if cursor is outside the window
sdl 1.3 probably supports changing system cursor, but it's only b&w and still, animated and colour cursors are on wishlist, and not on required features for 1.3/2.0. So I doubt there will be any cross-platform way to change cursor anytime soon, unless someone who needs it will implement this feature - do I see volunteer?zac352 wrote:There should really be an actual way to change the cursor.
Re: Detecting if cursor is outside the window
SDL 1.2 already supported changing the system cursor, but it only supports black & white cursors because that's a limit of many OSes and SDL has to respect the lowest common denominator.giniu wrote:sdl 1.3 probably supports changing system cursor...
Cheers,
Andre
Re: Detecting if cursor is outside the window
my mistake, never needed it and that's the reason I wasn't aware of it being here already. Anyway, in 1.3 whole input/output was rewritten once iirc, and I heard it will be rewritten again (tablet support was there, then disappeared from done things and it was rumoured to be back after stabilization of other parts, though not in current version), so you cannot be sure if it will be in 1.3 - it wasn't in required features in roadmap so it might as well go out I guess - also - I think black&white only cursors isn't really that useful. Useful cursor support might be added to 1.3, so that's far far away, and if you tracked development of 1.3 for some time, it might sound like "week after duke nukem forever"leiradel wrote:SDL 1.2 already supported changing the system cursor, but it only supports black & white cursors because that's a limit of many OSes and SDL has to respect the lowest common denominator.
Re: Detecting if cursor is outside the window
back on topic: you could calculate the mouse speed and if it very suddenly drops to zero near a screen edge, the mouse probably left the window.
Who is online
Users browsing this forum: No registered users and 99 guests