The Wayback Machine - https://web.archive.org/web/20190927100752/https://github.com/CosmosOS/Cosmos/wiki/Creating-a-GUI-Adding-the-mouse
Skip to content

Creating a GUI Adding the mouse

Quajak edited this page Jul 22, 2019 · 9 revisions

After you have intialised the screen, adding a mouse is quite simple.

//Initialise the canvas
var canvas = FullScreenCanvas.GetFullScreenCanvas();

To get the state of the mouse, you can use the MouseManager class in Cosmos.System.

First initialize the mouse with your screen size.

Sys.MouseManager.ScreenWidth = (uint)canvas.Mode.Columns;
Sys.MouseManager.ScreenHeight = (uint)canvas.Mode.Rows;

All that remains is to draw it, (note you want to redraw every frame)

Pen pen = new Pen(Color.Red);
int X = Sys.MouseManager.X;
int Y = Sys.MouseManager.Y;
canvas.DrawLine(pen, X, Y, X + 5, Y);
canvas.DrawLine(pen, X, Y, X, Y - 5);
canvas.DrawLine(pen, X, Y, X + 5, Y - 5);
You can’t perform that action at this time.