Notifications
Clear all
[Closed] rollout inside function of a struct cause struct member access requires instance
Apr 06, 2017 9:41 am
can someone explains why this isn’t working?
struct testbox
(
b = box(),
fn changeheight val =
(
b.height = val
)
)
struct testInside
(
ui = undefined,
c = testbox(),
fn changeheight val =
(
c.changeheight val
),
fn _ui =
(
rollout unnamedRollout "Change Height" width:162 height:54
(
spinner spn1 "" pos:[56,19] width:50 height:16
on spn1 changed val do
(
testInside.changeheight spn1.value -- this don't work
)
)
ui = unnamedRollout
createDialog ui
)
)
-- TEST
c = testInside()
c._ui()
c.changeheight 30 -- but this works
4 Replies
Apr 06, 2017 9:41 am
Just from a quick glance, inside the rollout, you are accessing struct def itself, which cannot work since it needs a struct instance (which is what you do at the end where you first create an instance and call its function which works).
Apr 06, 2017 9:41 am
For example
struct testbox
(
b = box(),
fn changeheight val =
(
b.height = val
)
)
struct testInside
(
ui = undefined,
c = testbox(),
fn changeheight val =
(
c.changeheight val
),
fn _ui =
(
rollout unnamedRollout "Change Height" width:162 height:54
(
local testInside
spinner spn1 "" pos:[56,19] width:50 height:16
on spn1 changed val do
(
testInside.changeheight spn1.value
)
)
createDialog unnamedRollout
unnamedRollout.testInside = this
)
)
c = testInside()
c._ui()
Apr 06, 2017 9:41 am
there is a “this” keyword?
and wow didn’t know that you can’t do a reference the rollout to an object… Thanks!