Hi guys… I have a maxscript issue but believe me… I really don’t know what’s happening here!!!
While refactoring my scripts I’m trying different ways to do stuff and I’m applying (hoping in the proper way) some hints taken “here and there” about rollouts and structs.
My problem is that a rollout opened with modal:true works properly… but if opened with modal:false (or without it) fails to access a private member of the owner struct
And the “fun fact” is that it fails only inside events like the on button pressed or on dropdownlist selected!
If you try to access the private member for example inside the on MainUI open block it’s ok…
I wrote an example script… its structure is exactly the same of mine, only simpler.
The button and the dropdown list both read the content of the private array _List and the events simply print the value.
Here the working snippet…
global myStruct ( struct myStruct ( private _self = myStruct, _List = #("AAA","BBB","CCC","DDD","EEE"), public fn CreateNew = _self(), mainUI = ( rollout mainUI "Rollout" width:300 height:200 ( local owner = if owner != undefined do owner button 'btn_1' "Btn" width:100 height:30 align:#center dropdownList 'ddl_List' "Account" align:#center label 'lbl_item' "--ITEM--" align:#center on mainUI open do ( ddl_List.items = owner._List ) on btn_1 pressed do ( print owner._List[ddl_List.selection] lbl_item.text = owner._List[ddl_List.selection] ) on ddl_List selected selectedItem do ( print owner._List[ddl_List.selection] lbl_item.text = owner._List[ddl_List.selection] ) ) ), fn ShowUI mode= ( createdialog mainUI modal:mode ), on create do mainUI.owner = this ) myStruct = myStruct() ok ) myStruct.ShowUI true
If you change the last line with
You’ll receive a
– MAXScript Rollout Handler Exception:
– Runtime error: Attempting to access private member: “_List” in: (myStruct mainUI:Rollout:mainUI)
I discovered this problem while trying to add a second rollout (declared in the same way) and created pressing a button in the first one: I’ve set the first rollout as modal:false and set true the second… so had the error.
Any help will be very very appreciated!!!