mousedown event for overlapping canvases

I’m digging through some very deferred code maintenance - migrating an oldish RealBasic project into current Xojo environment. I got the app to run with surprisingly few tweaks, but am getting unexpected behavior related to MouseDown events coming from small canvases that are on top of a larger canvas.

This portion of the app is very similar to any typical calendar interface. I have a larger canvas that is effectively “in back” and draws the grid and background of the calendar. The multiple events that populate the calendar grid are made with canvases in a control set that I multiply as the entries increase. The desired behavior is to have the smaller appointment canvas receive a mousedown event when clicked. I recall a big effort getting it right when I first made the RB app, but I eventually struck on the right code sequence that made it work.

In the Xojo environment, my appointment canvases aren’t getting the mousedown event fired. The “grid” canvas behind the appointment gets the mousedown event instead. The appointment canvas event code properly returns true. Stepping through the code indicates that the event isn’t even firing in the appt. canvas.

To troubleshoot, I made a new set of small canvases on top of the grid canvas and multiplied them in code. They tested correctly, and each received a mousedown event instead of the grid canvas behind.

I tried to delete my old appointment canvas (index: 0) and recreate it, thinking there might have been some baggage from the migrated RB control, but still no success.

I suspect the problem is in the sequence of my various graphic tasks, e.g. painting the grid, painting the appointment, painting a highlight around an appointment, etc. Xojo is handling these carefully sequenced tasks somehow differently from the way the old RB environment did. The appearance of the thing, appointments correctly positioned and obscuring the grid behind, all looks as it should.

Can anyone provide any tips here? Where should I look for likely culprit?

Thanks in advance.

First of all, it would have been much better to have used a single canvas and just drawn everything in one place. Overlapping canvases is going to cause you problems like this the more you have.

That said, make sure in your MouseDown events that you are returning True.

Otherwise, you should be able to use the coordinates of the mouse event to figure out which subcanvas it should have gone to and call a method on it. You’ll have to subclass canvas to do that though.