3dsmax question.
In the code below I create two buttons. I wanted to use the same object that I could update and use to setup data in each button. But I hit the wall. If I try to use object already created in my struct, inside button Event, I get:
Quote
struct MyContainer ( public lockView = true ) struct TestUI ( private text = "hello", _dataContainer = MyContainer(), public fn Create = ( rollout MainWindow "Test" ( button GI_btn @" GI " width:100 _height:30 pos:[20,40] button Farm_btn @" FARM " width:100 height:30 pos:[20, 70] /* EVENTS ---------------------------------------- */ on GI_btn pressed do ( _dataContainer.lockView = true ) on Farm_btn pressed do ( messagebox (_dataContainer.lockView as string) ) ) createDialog MainWindow 200 200 ) ) _ui = TestUI() _ui.Create()
Now if I modify the code:
struct MyContainer ( public lockView = true ) struct TestUI ( private text = "hello", public fn Create _dataContainer= ( rollout MainWindow "Test" ( button GI_btn @" GI " width:100 _height:30 pos:[20,40] button Farm_btn @" FARM " width:100 height:30 pos:[20, 70] /* EVENTS ---------------------------------------- */ on GI_btn pressed do ( _dataContainer.lockView = true ) on Farm_btn pressed do ( messagebox (_dataContainer.lockView as string) ) ) createDialog MainWindow 200 200 ) ) _my = MyContainer() _ui = TestUI() _ui.Create _myand try to pass data thru function and then use them in button events, i get:
Quote
So, how to correctly pass the same object into each button so I could work with the same data in each ?












