It looks like you're new here. If you want to get involved, click one of these buttons!
I would like to know if it is possible to draw a canvas object (rectangles, arrows...) by filling them in a particular color while using another color for the outline of the object?
Unfortunately that is not possible, but a nice work around would be to draw two shapes, the first one only outlined. The second one slightly smaller but filled.
You know what I mean?
Yes it is what I have done for now.
However I need an object to be clickable and not the other one. I could trick the script in ignoring clicks on this element but would there be a way to do it easily?
From what I noticed when I create canvas with for instance two objects:
my_canvas = canvas()
my_canvas['rect_green'] = Rect(0, 0, 100, 100, fill=True, color = 'green')
my_canvas['rect_red'] = Rect(0, 0, 100, 100, fill=True, color = 'red')
it is the second one created (the red rectangle here) that is visible;
if a click happens in the position of these objects and wh have:
my_mouse = Mouse(visible=True)
timestamp, (x, y), var.button = my_mouse.get_click()
var.element_clicked = my_canvas.elements_at(x, y)
var.element_clicked = [rect_green, rect_red]
So in case I cannot deactivate the click on a second object easily in my understanding:
Could you just confirm it is working like that? And if you have an idea for something more simple please let me know!
Well yes. It works just like in the real world. If one object covers the other (and they are opaque), you only see the one on top. In case of opensesame, the one that is drawn last. But still both objects exist at that location, so that you get both elements returned when clicked at.
Another solution is too simple draw a line for each edge of the rectangle. Like that you will only get one object returned when clicked on it. I'll have a look how easy it would be to implement separate arguments for fill and line color.