Related to my previous question. Any idea why when...
# korge
r
Related to my previous question. Any idea why when I draw a circle with filling the
onClick
and
onOver
doesn't work?
Copy code
// clicking DOES work
	val cicleStroke = graphics {
		stroke(
			ColorPaint(Colors.RED),
			Context2d.StrokeInfo(thickness = 1.0)
		) {
			circle(0.0, 0.0, 40.0)
		}
	}.xy(100.0, 100.0)
	cicleStroke.onClick {
		println("Clicked cicleStroke")
	}
Copy code
// clicking does NOT work
	val circleFilled = graphics {
		fillStroke(
			ColorPaint(Colors.LAWNGREEN),
			ColorPaint(Colors.BLACK),
			Context2d.StrokeInfo(thickness = 1.0 )
		) {
			circle(0.0, 0.0, 30.0)
		}
	}.xy(200.0, 100.0)
	circleFilled.onClick {
		println("Clicked circleFilled")
	}
n
Might be a bug .
beginFillStroke
does not return
Graphics
.
😱 1
d
Maybe we should inject the Graphics instance in the lambda, right?
n
I dont know what the
dirty
flag is doing but the
dirty
function returns
Graphics
on all the other drawing calls. Its only missing here
r
Do you know if/how I can workaround this by forexample something like overriding the
beginFillStroke
in my example?
Also for a first quick test if that will fix it
d
Maybe it is a 🪲 (the dirty part)
n
I dont know if there is a quick workaround with extension functions because there are private properties involved.
d
looks like it, but it is initially dirty, it shouldn't be a problem. BTW dirty is just to let the rendering to know that something has changed and needs to be recomputed
r
Any other tip how I can draw a circle and adding onClick functionality for now?
n
a regular circle?
Copy code
val circle = circle().onClick { println("I am a circle") }
r
Check, that's how I started by I moved to the graphics/VectorBuilder because I wanted a circle with a border.
Maybe more common to create sprites for this, instead of drawing it in code...