ScriptSpot

Forum topic · General Scripting

Coloured Buttons Please

By rodimus111 · 2011-03-22

Description

I need to do simple coloured buttons to my rollout just like the thepupettool script. I know I can do it with images, but I only need a fast and simple way to changes solid colors. Any Idea?

Comments (1)

Swordslayer · 2011-03-22

If you don't want to go the dotnet way, you can just change the .images property of button or use imgtag instead and change its .bitmap property (and you don't have to deal with the #(bitmap, alpha, 1,1,1,1,1) definition and get some extra functions as a bonus). For example:

try destroyDialog test catch()
rollout test "Test" width:200
(
	progressBar pbFrame width:52 height:22 enabled:false
	imgTag itColorful bitmap:(bitmap 50 20 color:red) pos:(pbFrame.pos+[1,1]) across:2	
	colorPicker cpChangeColor "Change color:" color:red width:115 pos:[75,6]

	on cpChangeColor changed val do
		itColorful.bitmap = bitmap 1 1 color:val
	
	on itColorful click do
		print cpChangeColor.color
)
createDialog test

Note that I used a disabled progressbar to frame the imgtag. That was just to give it some kind of a border and is quite hacky but it works...