Notifications
Clear all
[Closed] accessing ui elements from function triggered by callback
Aug 21, 2012 10:58 am
I’m trying to update my UI whenever a new file is opened.
I use the #filePostOpen callback and this triggers a function.
The problem I’ve got is that I cannot access the UI from the function.
I guess I’m missing something obvious here.
I tried to define the “lbl1” as a global, but that did not help.
I’ve stripped down the script to this easy test, run it – then open a scene.
fn refreshGUICallback =
(
print "this is inside the test function..."
lbl1.text = "Label updated from function, success."
)
rollout callbackUI "callback example" width:160 height:130
(
label lbl1 "supposed to be updated from callback function, open a file to trigger callback." pos:[8,8] width:144 height:71
)
callbacks.removeScripts id:#refreshGUICallback
callbacks.addScript #filePostOpen "refreshGUICallback()" id:#refreshGUICallback
MainUIFloater = newrolloutFloater "callback example" 180 140
addrollout callbackUI MainUIFloater
when you run it you get this error when opening a file:
---------------------------
MAXScript Callback script Exception
---------------------------
-- Unknown property: "text" in undefined
---------------------------
OK
---------------------------
2 Replies
Aug 21, 2012 10:58 am
Rollout UI items are never a global. They are in the scope of the rollout.
Aug 21, 2012 10:58 am
thank you for the help on this one, that’s very useful info!
It worked perfectly now.