Add control dynamically

  1. 5 years ago

    Luiz D'Aniello

    13 Mar 2019 User since 2019

    how can i add a button or any other control dynamically (by code)?

  2. Marc

    13 Mar 2019 User since 2018

    I don't think that's possible (yet?).

    I personally would especially like that in a Flex enabled container, because Flex is easier to use (regarding positioning) when adding controls dynamically.

  3. Luiz D'Aniello

    13 Mar 2019 User since 2019
    Edited 5 years ago by Luiz D'Aniello

    @Marc I don't think that's possible (yet?).

    I personally would especially like that in a Flex enabled container, because Flex is easier to use (regarding positioning) when adding controls dynamically.

    I discovered. If you use a View, you can use addSubView to add.

    func Load():
    var pb=Button(ButtonType.RoundedRect);
    pb.title="TEST";
    pb.backgroundColor=Color("a9aaaa");
    self.addSubview(pb);
  4. Marc

    13 Mar 2019 User since 2018
    Edited 5 years ago by Marc

    @Luiz D'Aniello I discovered. If you use a View, you can use addSubView to add.

    func Load(): var pb=Button(ButtonType.RoundedRect); pb.title="TEST"; pb.backgroundColor=Color("a9aaaa"); self.addSubview(pb);

    Ah, of course. I only checked the Creo View class and forgot to look at the parent classes (duh ...). But still, from my experience, I think using Flex would be much easier for positioning than using lay-out constraints from code.

or Sign Up to reply!