Accessing up the CC heirarchy

I have a button type which is a canvas in a ContainerControl. These buttons are instantiated in code and then I use EmbedWithin() to locate them within a buttonbar which is itself a ContainerControl.

Now, in normal use the user clicks the buttons to see different things in the main window. But I’d like a different mode where the user can drag/drop the buttons on the bar to rearrange them, and in this mode, clicking the buttons should have no effect. This would require having a state property that all buttons (in their mouseDown handler, for example) have access to. I’ve done this for one bar by creating a state property at the app-level, but it seems to me that this property really belongs in the bar itself. What I can’t figure out is the right syntax to use within the button’s mouseDown handler to access it.

I’ve tried such as self.parent.mystatevar but everything I try just gives a compiler error. What should I be doing?

Give the container an event “GetState” returning a boolean. Raise it up the chain until you are at the level where you have the state information.

Thanks; you’ve reminded me of something I’m already doing - with a similar button-bar even :rofl: only previously I was trying to call a method on the bar rather than access one of its properties. Trouble with getting old is, I forget that I’ve already solved what looks like a new problem in a slightly different context.

1 Like