Jump to content
  • Advertisement
Sign in to follow this  
CodaKiller

How to hide mouse cursor?

This topic is 3173 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 = 1024
GameWindow.height = 768
GameWindow.maximize = false
GameWindow.size = true
GameWindow.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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!