Structures in Canvas class

Good evening (o;

Let’s say I have a Canvas where I want to draw individual buttons.
A method called AddTab should add a new button with caption and other options.

Is structure the way to go to hold the buttons information like index, caption, flags?

And if so…how do I have to initialize it properly in my custom canvas class so I can add items to it and iterate through it?

muchas gracias from .ch
richard

1 Like

You place a button (outside of the Window),
you use New to create a new instance of that button
you set properties for this new button (location, name, etc.)

Doh: I forget how to place code inside the new button.

I paint my own buttons in my canvas class (o;

Okay…I have to add a structure to my canvas class, but also a property holding an array of it…

Now when I call AddTab I have to convert the Caption String to Byte().

Is there a built-in function that does that?

Don’t use structures unless you absolutely need them.
Better create a class that holds several properties instead of a structure.

Structures are mostly used for Declares.

1 Like

Excellent :slight_smile:

Slowly but surely I move forward with Xojo (o;

Never though of using a Class with properties and define a property with it as Array in a canvas class (o;

hyvää kiitokisa (o;
richard

There is an example called CanvasButton; I do not open it.

Already got a nice example project where I learned how to deal with events and event definitions…

The contextual mouse click can be solved also easily…if you return False in the event (o;