Jump to content

Window::Show/HideMouse not working as intended


 Share

Recommended Posts

Hello everyone,

 

I am experiencing some issues with the Window::Show/HideMouse methods. When calling both of them multiple times they basically stop working. For example:

 

bool App::Start()
{
//Initialize Steamworks (optional)
/*if (!Steamworks::Initialize())
{
System::Print("Error: Failed to initialize Steam.");
return false;
}*/
//Create a window
window = Leadwerks::Window::Create("cc");
window->ShowMouse();
//Create a context
context = Context::Create(window);

//Create a world
world = World::Create();

//Create a camera
camera = Camera::Create();
camera->Move(0,2,-5);

//Hide the mouse cursor
window->HideMouse();

std::string mapname = System::GetProperty("map","Maps/start.map");
Map::Load(mapname);

//Move the mouse to the center of the screen
window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2);

window->ShowMouse();
window->HideMouse();
return true;
}

 

In the above example the mouse pointer will be visible, but it should be hidden.

Link to comment
Share on other sites

At least for Windows, I assume LW is using the Win API ShowCursor function.

See here: http://msdn.microsoft.com/de-de/library/windows/desktop/ms648396%28v=vs.85%29.aspx

 

This function actually uses a counter, not just switching the cursor on/off. Starting with 0 = mouse ON (!).

 

Counting through your code:

 

Program Start: 0

Call to ShowMouse: 1

Call to Hidemouse: 0

Call to ShowMouse: 1

Call to HideMouse: 0

 

As Windows hides the mouse with counter -1 and below, it is never hidden - I think.

If this really is the case, the LW docs might need a bit of updating...

Link to comment
Share on other sites

I just call ShowCursor(). Did not know there was anything more complicated to it than that.

 

Added some internal logic that will make this work as expected.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...