CosmosOS/Cosmos

How to create a GUI with Mouse ?

Closed this issue · 4 comments

Area of Cosmos - 2022 dev kit

Expected Behaviour - I want a mouse

I want to create a GUI with mouse.
Here is my current code :

using System;
using System.Collections.Generic;
using Cosmos.System.Graphics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cosmos.System;
using Sys = Cosmos.System;

namespace WindOS.Graphics
{
    public class GUI
    {
        private Canvas canvas;
        private MouseState prevMouseState;
        private TabBar tabBar;

        public GUI()
        {

            this.canvas = FullScreenCanvas.GetFullScreenCanvas();
            this.canvas.Clear(Color.AliceBlue);

            this.prevMouseState = MouseState.None;

            this.tabBar = new TabBar(this.canvas);

            MouseManager.ScreenHeight = (UInt32)1080;
            MouseManager.ScreenWidth = (UInt32)1920;

        }

        public void HandleGUIInputs()
        {
            
        }
    }
}

I want to use the function "HandleGUIInputs()" to show the mouse.
I think that I should MouseManager.X and MouseManager.Y.
But I don't know how to exactly use it.
This is just a sub file and not the Kernel.cs.
The linking and all stuff works perfect and I have tested it with many shapes.
I just want it to show a mouse like a big dot or something like corsshair.

You should just draw an alpha image or just a filled rectangle for test:
this.canvas.DrawFilledRectangle(Color.Black, MouseManager.X, MouseManager.Y, 10, 10);

yes I did it but the screen gets flooded with the rectangles.
I think so to delete the previous rectangle somehow.

Uhh you are not clearing your canvas. You can see a small cosmos OS here. Also with such things it's best to go to the official cosmos discord or discussions on github

Thank you It helped a lot.
I think so I should close it.