Help with Resizing rollout based on Subrollout "rolledUp"

Hello Guys, im working on a personal project Im trying to create a rollout with some subrollouts the idea is to resize the mainrollout based on the "RolledUp" state of the subrullouts and move the available buttons, but i ran into some issues:

  1.  By using MainRollOut.height += subrollout2.height is increasing the Mainrollout size when opening the Mainrollout 
  2.  When changing the position of the buttons in the mainrollout, the buttons stop working, (like if they are behind and click is not available anymore.


I will really appreciate any help or feedback


----------------------------- Script ---------------------------------

try(DestroyDialog MainRollOut)catch()

rollout MainRollOut "Test Rollout" width:325 height:180


subRollout SubrolloutMain height:125 align:#center

button btnMainrollout1 "Button 1" align:#left width:100 offset:[45, 0]

button btnMainrollout2 "Button 2" align:#left width:100 offset:[150, -26]



rollout subrollout1 "Test Rollout" width:325 height:300


button btnsubrollout1 "Button 1" align:#center



rollout subrollout2 "Test Rollout" width:325 height:300


button btnsubrollout2 "Button 1" align:#center 


on subrollout2 rolledup bState do  <---------------------------------------- HERE


if (bState == true) then


MainRollOut.height += subrollout2.height

MainRollOut.height += 1

--MainRollOut.height += subrollout2.height





MainRollOut.height -= subrollout2.height

MainRollOut.height -= 1




--label_linfo.pos=[28,newmain - 15]







createDialog MainRollOut pos:[1400,100]

addSubRollOut MainRollOut.SubrolloutMain subrollout1

addSubRollOut MainRollOut.SubrolloutMain subrollout2