Using a Custom Attribute Rollout in a dotnet TabControl


#1

As the title says, I am trying to get the rollout of my Custom attribute to show up in my TabControl UI. Now the funny thing is is that it seems to work on initial viewing of the tab. (In my example, tab 2). However, when I switch back and forth, the live-link between the Attribute and the Rollout seems to be destroyed and changing the values afterward doesn’t affect the Attribute values anymore.

I think it has to do with the way the rollouts are being removed from the subrollout beneath the TabControl each time I switch tabs.

Does any of you know if there are less destructive ways to show or hide subrollout, or ways to keep the live-link persistent between the attribute and the rollout?

example script:

testCA = attributes test_a
attribID:#(0x12a36030, 0xb9029da)
(
    parameters test_p rollout:test_r
    (
	testval type:#float default:0.01  ui:hits
    )
    rollout test_r "test rollout"
    (
	spinner hits "floatval " type: #float
    )
)
custAttributes.add rootnode testCA

(	
global testTabs 

try(destroyDialog testTabs )catch()

local LastSubRollout = 1

rollout testTabsRollout01 "Rollout 01"
(
	colorpicker clr_picker "Color Picker"
)
rollout testTabsRollout03 "Rollout 03"
(
	colorpicker clr_picker "Color Picker"
)

testTabs_Rollouts = #(
	#("Tab CA",#(testTabsRollout01)),
	#("Tab Two",#(rootnode.test_a.test_r)),
	#("Tab Three",#(testTabsRollout03))
)	

rollout testTabs "Test Tabs"
(
		dotNetControl dn_tabs "System.Windows.Forms.TabControl" height:20 width:420 align:#center
		subRollout theSubRollout width:420 height:440 align:#center
		
		on dn_tabs Selected itm do
		(
			if LastSubRollout != (itm.TabPageIndex+1) do --do not update if the same tab clicked twice
			(
				for subroll in testTabs_Rollouts[LastSubRollout][2] do	
					removeSubRollout theSubRollout subroll
				for subroll in testTabs_Rollouts[LastSubRollout = itm.TabPageIndex+1][2] do	
					addSubRollout theSubRollout subroll
			) 
		)--end tabs clicked		
		
		on testTabs open do
		(
			for aTab in testTabs_Rollouts do
			(
				dn_tabs.TabPages.add aTab[1]
			)
			for subroll in testTabs_Rollouts[1][2] do 
				addSubRollout theSubRollout subroll				
		)
)

createDialog testTabs 440 500
)

#2

Ok, I figured out that using a function within the Custom Attribute to retrieve the attributes rollout works. Calling this function when adding subrollouts does the trick. Since scripted attributes are so similar to scripted plugins I found this solution by PEN (thanks Paul)
https://forums.cgsociety.org/t/how-to-add-scripted-plugin-rollouts-to-subrollout/1566231

so within the custom attribute I add:

fn getRollout = test_r

then later on when adding the subRollouts I use the line:

addSubRollout theSubRollout (rootnode.test_a.getRollout())

Too bad I cannot store the rollouts in an array and work from there, but at least this works.

Still don’t understand why the live-link is being destroyed. My guess is that the removeSubrollout is to blame.