Programming from scratch with XOjo: how to use ContainerControl

    Programming from scratch with XOjo: how to use ContainerControl

    In the previous chapter of the “Xojo Programming Course” we started to see how we can use ContainerControl when creating and using compound graphical user interface controls in our applications.

    Its power and flexibility is such that it is worth pausing to look a little more in detail at the fundamentals of using this class that will allow us not only to use the control in the design phase of our applications (i.e. from the Xojo IDE) , but also how we can add ContainerControl-based controls at runtime.



    For example, this means that while your applications are running you will be able to write code that allows you to create new instances based on your ContainerControls to add them to windows or other views in which you are interested in appearing. What sounds good?

    Well, to do this kind of thing you will just have to invoke the EmbedWithin method on the ContainerControl instance you want to add as a new view (or control) in a certain view or window.

    Therefore, throughout this tutorial you will see, from start to finish, the main areas of interest that will allow you to use ContainerControls more freely in your projects (and remember that you can use them in your web projects too!).

    Also, you will see what strategies you can use so that the controls used in the design of your ContainerControls can "communicate" with the view in which they will eventually be used… and vice versa.

    We will also explore the concept of Classes a little more. Specifically, in this tutorial you can see what a subclass is and how it is useful. In summary, it is how we need to add common behaviors and properties to a "root" class that will be inherited (and therefore available) to any other subclass or subclass based on it.



    Similarly, and since ContainerControls can be added at runtime, we will also see during the tutorial how to "delegate" the execution of any of the defined events to the method we want.


    Event delegation is a very powerful way to change the behavior of an object, since we can determine during the execution of our applications the code we want to execute in response to the activation of one event or another; and how the delegate method can be changed at any time, how can we also do it so that one or the other is executed depending on whether certain conditions are met.


    As usual, I encourage you not only to watch the tutorial but also to try to reproduce it and, subsequently, to try to put into practice what you have learned (seen) by creating your own example project.

    Javier Rodriguez

    Xojo engineer

    Twitter: @xojoes

    Facebook:  http://facebook.com/xojoes/

    Download the latest version from www.xojo.com

    Xojo Resources in Spanish: https://docs.xojo.com/spanish

    add a comment of Programming from scratch with XOjo: how to use ContainerControl
    Comment sent successfully! We will review it in the next few hours.