Notifications
Clear all

[Closed] Radiobuttons : #offsets parameter rules

here is a universal test…

try(destroydialog rol) catch()
rollout rol "Test Rollout" width:1000
(
	local lbs = #("1","2","3","4")
	
	radiobuttons rb1 labels:lbs columns:4 align:#left --offsets:#([0,0],[0,0],[0,0],[50,0])
	radiobuttons rb2 labels:lbs columns:4 align:#left offsets:#([0,0],[200,0],[0,0],[100,0])

	label info align:#left enabled:off offset:[0,8]

	on rol open do
	(
		pp = for k=1 to 4 collect
		(
			p = windows.getWindowPos rb1.hwnd[k]
		)
		
		ss = stringstream ""
		dd = for k=1 to 4 collect
		(
			p = pp[k]
			d = windows.getWindowPos rb2.hwnd[k]
			
			dx = d.x - p.x 
			format "%(%,%) " dx p.w d.w to:ss

			d
		)
		info.text = ss as string
	)
)
createdialog rol

according to your formula the second item should be:
(1*200) + 0 = 200

but it’s on 400px

Oh! my fault… we have to add item’s offset, right?

(1*200) + 200 = 400… looks right

Yes, that would be it. Needs to be different for other alignments or text labels I guess.
Here is a modified version of your script to test it randomly:

try(destroydialog rol) catch()

rollout rol "Test Rollout" width:700
(
	local offsets = for j = 1 to 5 collect random [0,0] [100,0]
	local lbs = #("1","2","3","4","5")
	
	radiobuttons rb1 labels:lbs columns:5 align:#left
	radiobuttons rb2 labels:lbs columns:5 align:#left offsets:offsets

	label info  width:700 height:24 align:#left enabled:on offset:[0,8]
	label info2 width:700 height:24 align:#left enabled:on offset:[0,8]
	
	on rol open do
	(
		pp = for k=1 to 5 collect
		(
			p = windows.getWindowPos rb1.hwnd[k]
		)
		
		ss = stringstream ""
		format "Real Values\n" to:ss
		dd = for k=1 to 5 collect
		(
			p = pp[k]
			d = windows.getWindowPos rb2.hwnd[k]
			
			dx = d.x - p.x
			format "%\t" dx to:ss

			d
		)
		info.text = ss as string
		
		-- Predicted values ---------------------------------------------
		o1 = offsets[1][1] as integer
		o2 = offsets[2][1] as integer
		o3 = offsets[3][1] as integer
		o4 = offsets[4][1] as integer
		o5 = offsets[5][1] as integer
		
		ss = stringstream ""
		format "Predicted Values\n" to:ss
		
		mmax = amax o1 o2 o3 o4 o5
		
		o2 = (mmax * 1) + o2
		o3 = (mmax * 2) + o3
		o4 = (mmax * 3) + o4
		o5 = (mmax * 4) + o5
		
		format "%\t%\t%\t%\t%" o1 o2 o3 o4 o5 to:ss
		
		info2.text = ss as string
		-- Predicted values ---------------------------------------------
	)
	
)
createdialog rol

the problem is how to make a horizontal group of radio buttons with a given spacing between them…
it sounds silly, but the best way to achieve this is to use a vertical group:

try(destroydialog rol) catch()
rollout rol "Test Rollout" width:700
(
	local lbs = #("1","2","3","4")
	
	radiobuttons rb1 labels:lbs columns:4 align:#left --offsets:#([0,0],[0,0],[0,0],[50,0])
	radiobuttons rb2 labels:lbs columns:1 offsets:#([0,0],[100,-15],[200,-30],[300,-45]) align:#left
	
	label info align:#left enabled:off offset:[0,8]

	on rol open do
	(
		pp = for k=1 to 4 collect
		(
			p = windows.getWindowPos rb1.hwnd[k]
		)
		
		ss = stringstream ""
		dd = for k=1 to 4 collect
		(
			p = pp[k]
			d = windows.getWindowPos rb2.hwnd[k]
			
			dx = d.x - pp[1].x 
			format "%(%,%) " dx p.w d.w to:ss

			d
		)
		info.text = ss as string
	)
)
createdialog rol
Page 2 / 2