
Xojo array of controls code#
This way, RaiseEvent Open will call the Open Event to the instance and will let our class user write and execute additional code during the control initialization. What does RaiseEvent Open mean? Notice that we are setting our class behavior so if we are using the Open Event on it, this Event will not be available for implementation for any of the instances created from the class.įixing this is really simple: add a new Event Definition to the class using the following values in the associated Inspector: To do that, add the Open Event Handler to the class and write the following snippet of code in the associated Code Editor: Sub Open() Handles Open A good way to learn this is using the Open Event, so during the instance initialization it has the opportunity to add itself to the shared array and also to set its own index value. We also need to know in runtime how many instances we are using. For this, nothing works better than setting a new Property (this time, a regular or instance Property) and assigning its data type as Integer: Of course, we need a way to reference every instance created from the class for example, when we need to send a message to only one of them and not to all the available instances. That means that this will be visible only from the code executed inside the class. The fact that this is a Shared Property means that it (and its stored values) will be available for all the class instances (objects) created from the class while the regular properties allows us to store distinct values for each class instance.Īnother detail is that, in this case, we have limited the Scope for the Shared Property to Private. With the created class still selected, add a new Shared Property from the Insert menu and use the Inspector with the following values: For this, nothing is better than adding a Property to our class whose data type is an array storing objects from our class. Next, we will need a data type acting as a storage reference for every instance (in our example, buttons) we want to add to our UI layout. (Obviously, you can change these for any others you need.) Creating an array to keep references to the instances


For this example, use the following values: All of this without knowing in advance, at runtime, how many of such instances are placed in the layout.Īn inconvenience of this feature is that you can’t use it when the graphic controls are placed on a ContainerControl due to the way ContainerControls are implemented. The good news is that this problem has an easy solution! Read on to learn about it:įirst, create subclasses from those Framework controls you want to use as a Control Set this also applies when creating your own graphic controls from scratch.įor that, add a new Class to a Xojo project from the Insert menu and use the Inspector to set the class name and the Parent class it is derived from. For example, this allows us to invoke a method in a concrete instance, based on its control index, or invoke the same method to all of them (iteration). crashes when TextField.A Control Set is the feature to use when there are several instances in a Window’s layout and you need to command (or access them) from code, both for those available by default in the Framework and ones based on your own graphic classes. a constant to a class cant use an expression while one in code can Reproducible

to a case will cause search results to change whats viewed when you close the case you subscribed to Verified

migration assistant generates projects that are missing what appears to be an entire “VB” namespace Needs Review a constant in the font editor tab of the inspector may not stick for some controls Reproducible conjoins headers that RFC says should not be Verified a xojo employee comments on a case privately the end user (ie/ not a xojo employee) can see that updated time stamp and no comment Reproducible Searching in Xojo’s Feedback is difficult if you dont use the right key word or the same keyword This is intended to be a cumulative list of known open bugs so anyone can easily find reports that might affect them
