The mouse cursor behavior gets kinda ridiculous when having set a shape (not using the OS default). Basically I just want to be able to toggle between “mouse cursor mode” and “camera/movement mode” like many games do.
SharedPtr<Cursor> cursor;
...
// starting phase
XMLFile* style = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
UI* ui=GetSubsystem<UI>();
ui->GetRoot()->SetDefaultStyle(style);
cursor=new Cursor(context_);
cursor->SetStyleAuto(style);
ui->SetCursor(cursor);
GetSubsystem<Input>()->SetMouseVisible(true);
...
// in my toggle function
GetSubsystem<Input>()->SetMouseGrabbed(!GetSubsystem<Input>()->IsMouseGrabbed()); // toggle grabbing of mouse
GetSubsystem<Input>()->SetMouseVisible(!GetSubsystem<Input>()->IsMouseVisible()); // ignore mouse cursor (the cursor is still visible but weird when having set a cursor)
if(GetSubsystem<UI>()->GetCursor()) // toggle the set cursor to 0 to have the default OS cursor again, which is hidden via SetMouseVisible
GetSubsystem<UI>()->SetCursor(0);
else
GetSubsystem<UI>()->SetCursor(cursor);
Maybe I’m missing something but such a mode switch shouldn’t be that complicated and hard to do as it currently is.
What about a ui->SetCursorActive(bool) that does basically ui->SetCursor(0) and Input->SetMouseVisible(false) in the false case or SetCursor(last_cursor) and Input->SetMouseVisible(true) in the true case?
There could be also ui->EnableCursor() and ui->DisableCursor().
Am I doing it right and is this intended to be like this?
Urho version is the newest from GitHub and 1.5 behaves the same.