Jump to content

Window::GetCursor()


reepblue
 Share

Recommended Posts

I'm trying to fix a bug in my application where if the mouse cursor switching works after the window is rebuilt. What I need to do is reset the cursor to default before I destroy the window and then reapply the old cursor after the window is rebuilt. I need a Window::GetCursor() function to do this and none exists. 

	bool GraphicsWindow::Initialize(const WString& title, const int width, const int height, shared_ptr<Display> display, const GraphicWindowStyles style)
	{
		// Release existing pointers so we can rebuild!
		static bool firstwindow = true;

		// Set the cursor to default before we delete the window.
		MouseCursor current_cursor = CURSOR_DEFAULT;
		if (window)
		{
			// I need this function.
			current_cursor = window->GetCursor();
			window->SetCursor(CURSOR_DEFAULT);
		}

		window = NULL;
		framebuffer = NULL;

		int w = width;
		int h = height;

		WindowStyles window_style = WINDOW_TITLEBAR | WINDOW_CENTER | WINDOW_HIDDEN;
		switch (style)
		{
		case GRAPHICSWINDOW_TITLEBAR:
			window_style = WINDOW_TITLEBAR | WINDOW_CENTER | WINDOW_HIDDEN;
			break;

		case GRAPHICSWINDOW_BORDERLESS:
			window_style = WINDOW_CENTER | WINDOW_HIDDEN;
			break;

		case GRAPHICSWINDOW_FULLSCREEN:
			window_style = WINDOW_FULLSCREEN | WINDOW_CENTER | WINDOW_HIDDEN;
			break;

		case GRAPHICSWINDOW_FULLSCREENNATIVE:
			w = display->size.x;
			h = display->size.y;
			window_style = WINDOW_FULLSCREEN | WINDOW_CENTER | WINDOW_HIDDEN;
			break;

		default:
			break;
		}

		windowtitle = title;
		window = CreateWindow(windowtitle, 0, 0, w, h, display, window_style);
		SetWindowTitlebarTheme(window, TITLEBAR_DARK);
		framebuffer = CreateFramebuffer(window);

		if (firstwindow)
		{
			splashscreen = std::make_shared<SplashScreen>();
			splashscreen->Initialize(window, 1500);
			firstwindow = false;
		}
		else
		{
			window->SetHidden(false);
		}

		// Set this to focus!
		window->SetCursor(current_cursor);
		window->Activate();

		// Send this event with the size of the framebuffer.
		EmitEvent(EVENT_GRAPHICSWINDOW, GetProgram(), 0, window->GetPosition().x, window->GetPosition().y, framebuffer->GetSize().x, framebuffer->GetSize().y, window);
		return true;
	}

 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...