0x4c756e61/NiGUI-docs

[help needed] draw pixel when clicking mouse

LazyGamer1111 opened this issue · 0 comments

I want to draw a pixel when i click with the mouse, this is my code rn
`import nigui

app.init()
var window = newWindow()
window.width = 500
window.height = 500

var control1 = newControl()
window.add(control1)

control1.widthMode = WidthMode_Fill
control1.heightMode = HeightMode_Fill

control1.onMouseButtonDown = proc (event: MouseEvent) =
let canvas = control1.canvas
echo(event.button, " (", event.x, ", ", event.y, ")")
canvas.setPixel(event.x, event.y, rgb(0, 0, 0))

window.show()

app.run()`
It doesnt work and says that the canvas is not in draw mode.
What did i do wrong?