How to hide mouse cursor?

Started by
17 comments, last by benryves 14 years, 5 months ago
This is more complex then the average problem of hiding the mouse cursor, I have no window to hide the mouse with, how can I hide it on a global scale?
Remember Codeka is my alternate account, just remember that!
Advertisement
It doesn't sound like anything that a game should do.. why do you need that?
Quote:Original post by snake5
It doesn't sound like anything that a game should do.. why do you need that?


My game engine has programmable windows and there is not always going to be a window to hide the mouse cursor.
Remember Codeka is my alternate account, just remember that!
I assume you've already tried ShowCursor with unsatisfactory results?

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Quote:Original post by ApochPiQ
I assume you've already tried ShowCursor with unsatisfactory results?


Only works over a window owned by the instance of the application.
Remember Codeka is my alternate account, just remember that!
You're not really supposed to hide the cursor anywhere else. Your program is the window, and outside of it the user might have other programs you shouldn't mess with. I assume you're only drawing inside your window, so why would you hide the cursor anywhere else?
It's bad etiquette to hide the cursor over windows you don't own.

I also don't see how having "programmable" windows causes issues; if there's no window for your app, then why do you need to be hiding the cursor?

Maybe if you start from the top and explain what you're trying to accomplish we can figure out a solution that works and is polite to other software.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Not to be pedantic, but if possible, you might at least want to ensure that the cursor is restored in case of a program crash. You don't want to leave your users with a mouseless operating system.
Quote:Original post by ApochPiQ
It's bad etiquette to hide the cursor over windows you don't own.

I also don't see how having "programmable" windows causes issues; if there's no window for your app, then why do you need to be hiding the cursor?

Maybe if you start from the top and explain what you're trying to accomplish we can figure out a solution that works and is polite to other software.


In my game engine I have a window class which is used in a script to create windows, example:

GameWindow = create_window()GameWindow.title = "Game Demo"GameWindow.width = 1024GameWindow.height = 768GameWindow.maximize = falseGameWindow.size = trueGameWindow.icon = "Default.ico"GameWindow.show_cursor = false



I've made it so that the window class can hide the cursor when it is over the window, I can set some windows to show the cursor and others to hide it.

This is a useful feature but when I am trying to control the camera for a 3D game it lets the mouse move freely around and if the user clicks to fire a weapon it could for instance click My computer or something and open a window while the player is playing.

This is unacceptable, I can create a function which binds the mouse to a window but I would prefer to just disable the cursor altogether and enable it when the program closes or when focus is changed to another application.

I'm not sure if there is a way to do this so that the cursor will always return even if the program crashes or if this can be done at all.
Remember Codeka is my alternate account, just remember that!
Hiding the cursor does nothing for this problem, as even if the cursor is hidden, clicks still work. Somehow disabling mouse clicks would be a very bad idea and probably wouldn't reset itself if your program crashed, or if you fail to handle switching programs correctly. Constrain the mouse to your window instead, as all other games do. It is an easier and a better solution.

This topic is closed to new replies.

Advertisement