“Hierarchical” Artwork in Canvas

I want to present, dynamically, three rectangles in a Canvas.

Large Canvas draw everything.
One Master RoundRect (for example)
Many Child RoundRect on click in of the above RoundRect
One larger RoundRect on click in one of the above RoundRect

I Hope this is clear.

At first, I simply draw using standard Graphics “calls”, and the graphics were nice. I let time ellapsed and yesterday I wanted to go ahead but I had no idea on how to link the click (from MouseDown) and the drawing of the others RoundRect.

Then, yesterday, I decided to use Object2D, etc. (same as above.

What I understand is that I (apparently) need to compute the figures locations and act - in MouseDown - accordingly (display what I have to display).
If so, I have to keep the locations of the two sets of objects that can be clicked in and draw what have to be draw.

Am I right ?

Yes. As usual: show us your code.

Size, colors and X,Y (+ Text below) changed from:

Dim r As New RoundRectShape r.Width = 75 r.Height = 75 r.Border = 100 // * r.BorderColor = RGB(0, 0, 0) r.FillColor = RGB(255, 102, 102) r.CornerHeight = 15 r.CornerWidth = 15 r.BorderWidth = 2.5 g.DrawObject(r, 150, 150)

and

Dim s As New StringShape s.X = 20 s.Text = "Hello World" s.HorizontalAlignment = StringShape.Alignment.Left // ** g.DrawObject(s)

The text is draw inside the RoundRectShape (Left and Right Aligned) in two StringShape(s).

For testings, I add code in the Target Canvas’ .MouseDown to determinate if a click was done inside the main (Master) RoundRectShape. No Code added for the Child(s) or Grand-Child(s) yet; they are generated automatically at know location(s).

  • I do not know why, but “my” original code does not have this line and so the Border color was not displayed (of course, border was transparent). As usual, I wasted time on that one. I may have changed my mind somewhere while developing the project.

** This is faster to understand the how to vs the bitmap counterpart (who was easy to code, but far more difficult to get the correct result on screen :frowning: ).

BTW: I do not really need Object2D or Bitmap graphics (because both generate vector graphics in the PDF/macOS). I just probably had a bad memory: I was thinking that a click in the Canvas allows me to know what object was behind “automagically”. I do not found that in the LR.

Edit:
I was waiting for a meeting at a local “Bundesagentur für Arbeit” yesterday afternoon and takes that opportunity to develop the Object2D version, without internet access, yesterday afternoon.

Emile, take a look at Examples>Graphics and Multimedia>CanvasDragRect and CanvasDrawDrag to see if they help.

I forgot to make my home work !

Sorry.

Thanks Julian: it helps.

Too much complex for right now. I will go back there.

Could be fantastic to create a game…

First attempt to locate the shared examples failed: I loaded the example:
ObjectsInCanvas>ObjectsInCanvas.xojo_binary_project

And this is really complex. Now, I checked more carefully the examples names and they are nice.

Thank you Julian.