Notifications
Clear all

[Closed] Member vars inside a rollout inside a struct

Hi

I am wondering the correct way to assign a var that is in myStruct from within a function, in a a rollout, in the button press event.

Struct myStruct 
(
    Var,

    Fn showUi =
    (
        Rollout "blah" .........
        (
           Button "pressme" ......

            On pressme pressed do
             (
                   this.Var = 7 -- the "this" is apparently referencing the rollout not the struct
             )
        )
    )
)

Someone mentioned you need to set the rollout.owner property to “this” but the owner property is read only so it fails.

Any help would be appreciated
Dave

3 Replies

I do this all the time by referring to variables by the struct instance name instead of this.


Struct myStruct 
(
    Var,

    Fn showUi =
    (
        Rollout "blah" .........
        (
           Button "pressme" ......

            On pressme pressed do
             (
                   myStructInstance.Var = 7 -- the "this" is apparently referencing the rollout not the struct
             )
        )
    )
)

then


myStructInstance = myStruct()
myStructInstance.showUi()

Cheers for the reply but that only works if you only have one instance of your struct, say you wanted to have a struct that was uniquely identify able by name for example, you would not e able to do that because ou would always be modifying a single instance

I usually do this:

Struct myStruct 
(
    self,
    Var,


    Fn showUi =
    (
        Rollout "blah" .........
        (

        On pressme pressed do
             (
                   self.Var = 7
             )
        )
    )
)

myStructInstance = myStruct()
myStructInstance.self = myStructInstance