I am reworking a script for my company, and i was looking into ways of restructuring a very long, linear script (over 4k lines) into something more manageable, using Struct’s and “includes”.
so far, most of the script had been restructured using the workflow mentioned above, and works as expected, using hard-coded approach, where i call/set things directly. Now, this is time to try and hook it all up with my UI, that had also been separated into its own Struct.
I can create and show my Rollout, but i seem to struggle with understanding of how to get to my buttons, drop-down menus, etc… from my main script… Unfortunately, i cannot show majority of my code here, due to company’s policy, (sorry :no:).
here is stripped snippet:
(
fn getRollout =
(
rollout rigRollout ("Rigger") width:200 height:575
(
edittext charName "Character name:" labelOnTop:false pos:[10,25] visible:true
dropdownlist module "Add module: " items:#("Core","Spine","Head") pos:[10,60]
label parent "Parent: " width:40 pos:[10,105]
button pressMe "Press me" width:140 pos:[50,105]
)
return rigRollout
),
fn show =
(
try(destroyDialog rigRollout)
catch()
newRollout = getRollout()
createDialog newRollout
)
)
stripped version of my UI, i got rid of everything, except for a button, and left everything wrapped in a struct. COPY/PASTE should be fine to make this work.
Here is the code that i wrote to test and try to get something out of my button. In reality, i would getting some data from the user/scene, but in this test, i would like to atleast get this button to print something for me.
include @"ViewUtils.ms"
myUi = rigUi()
myRollout = myUi.getRollout()
myButton = myRollout.pressMe
on myButton pressed do (
print "Press Me - Ok"
)
myUi.show()
I am coming from python, and therefore i understand that my button inside the ViewUtils should trigger/send some sort of callback to get INITed in once the UI-object was created, but not sure what should i do here, in maxscript.
anyone has a suggestion on what approach i should take? thanks for view this guys, appreciate any feedback.