Checkbutton highlightColor update trick

Hey,
I just found out a little trick that I thought might be worth sharing.
It is nice that you can set a custom highlightColor for checkbuttons inside a rollout. However, changing that color while the script runs, e.g. to reflect some user decisions like some radiobutton state, does not work so great. It will update only when you hover over the checkbutton, move the rollout off screen or toggle the checkbutton twice.

But you can force it to update by setting the caption to something different! I was happy to find that out, so maybe it is useful to someone else.

This little example explains it better:

rollout ro_checkbuttonColorUpdate "CKB color update" width:168 height:137
(
	colorPicker cp_ckbColor "" pos:[59,9] width:50 height:50 color:(color 10 60 140)
	checkButton ckb_delayed "Color update on hover" pos:[7,70] width:154 height:28 checked:true
	checkButton ckb_instant "Instant color update" pos:[7,104] width:154 height:28 checked:true
 
	on cp_ckbColor changed clr do
	(
		ckb_delayed.highlightColor = clr
		ckb_instant.highlightColor = clr
 
		-- force color update:
		ckb_instant.caption = ""
		ckb_instant.caption = "Instant color update"
	)--end on
)
createDialog ro_checkbuttonColorUpdate

Cheers

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

Resources

My half scripts on this forum are combination of mxs+dotNet (i don't use C# or any other programing language)
I learn a lot from here:
http://forums.cgsociety.org/showthread.php?f=98&t=551473
Also here you can find good stuff about all controls
.Net >>> http://msdn.microsoft.com/en-us/library/gg145045%28v=VS.110%29.aspx
DevXpress >>> http://documentation.devexpress.com/#HomePage/CustomDocument9453
And most useful mxs tool by Alexander Kramer (Track)
http://www.scriptspot.com/3ds-max/scripts/show-dotnet-properties

barigazy

barigazy's picture

edit

But dotNet in most cases have problem with GarbageCollections when
you play with Paint events. I stop to develop this tool because of that.
http://www.mediafire.com/download.php?abh7dddpsj8sl72
And last something that will use in the near future (max2012 and max 2013 already supports most of ctrl's) DevXpress UI controls like this funny tool http://www.scriptspot.com/3ds-max/scripts/ineractive-labels

barigazy

br0t's picture

these are great links, thanks

these are great links, thanks alot branko! You did some badass GUI stuff there :D really cool to see what is possible

Never get low & slow & out of ideas

barigazy's picture

I'm glad you like it.:)

I'm glad you like it.:)
I sent you a PM with a link

barigazy

br0t's picture

hehe nice tool :P yeaah

hehe nice tool :P yeaah dotNet, so powerful but I still didnt get to use it that much, dunno where to start I guess... do you know some good resources?

Never get low & slow & out of ideas

barigazy's picture

:)

Very cool trick i admit.
I love to see colored UI. MXS rollout is limited but dotNet forms and controls are not.
I play with this to get some screen color for my custom solor picker tool.

(
try(form.close()) catch()
local sfIdx, clock
fn defColor r g b = ((dotNetClass "System.Drawing.Color").FromArgb r g b)		
fn defPoint x y = (dotNetObject "System.Drawing.Point" x y)	
fn defSize x y = (dotNetObject "System.Drawing.Size" x y)
clock = dotNetObject "Timer" ; clock.Interval = 10
Clr = defColor 0 0 0 ; ClrBG = defColor 60 60 60 ; ClrFG = defColor 200 200 200
fn defSmplClrLbl dnLbl w h locX locY clr = 
(
	dnLbl.Size = defSize w h ; dnLbl.Location = defPoint locX locY
	dnLbl.BorderStyle = dnLbl.BorderStyle.FixedSingle ; dnLbl.BackColor = clr
)
fn defBtn dnBtn w h locX locY txt =
(
	dnBtn.Size = defSize w h ; dnBtn.Location = defPoint locX locY ; dnBtn.Text = txt 
	dnBtn.BackColor = ClrBG ; dnBtn.ForeColor = ClrFG ; dnBtn.FlatStyle = dnBtn.FlatStyle.Popup
)
fn defForm dnForm w h x y =
(
	dnForm.ShowInTaskbar = false ; dnForm.Text = "Get pixel color" ; dnForm.ClientSize = defSize w h
	dnForm.StartPosition = dnForm.StartPosition.Manual ; dnForm.DesktopLocation = defPoint x y
	dnForm.FormBorderStyle = dnForm.FormBorderStyle.FixedSingle
	dnForm.MaximizeBox = dnForm.MinimizeBox = off
)
fn getPixClr = 
(
	local theBmp = dotnetObject "System.Drawing.Bitmap" 1 1
	local gfx = (dotNetClass "System.Drawing.Graphics").fromImage theBmp
	gfx.copyFromScreen mouse.screenPos[1] mouse.screenPos[2] 0 0 thebmp.size
	local col = theBmp.getPixel 0 0
	gfx.dispose()
	theBmp.dispose()
	return col
)
fn filtMMMT node = isKindOf node mmmt
fn getSFIDX = (for i = 1 to GetNumberSelectFilters() where GetSelectFilterName i == "mmmt" collect i)	
fn registerSF = (if (getSFIDX()).count == 0 do registerSelectFilterCallback filtMMMT "mmmt")
 
 
-----------------------------------------------------------------------------------------------------
 
form = dotnetobject "MaxCustomControls.Maxform" ; defForm form 200 40 10 110
pickBtn = dotnetobject "Button" ; defBtn pickBtn 100 30 95 5 "Pick Color"
pixClr = dotnetobject "Label" ; defSmplClrLbl pixClr 85 30 5 5 Clr
fn buttonClick s e = 
(
	s.BackColor = clr ; clock.Start()
	mmmtSFIDX = (getSFIDX())[1]
	if GetSelectFilter() != mmmtSFIDX do (sfIdx = getSelectFilter() ; setSelectFilter mmmtSFIDX))
fn butonLF s e = 
(
	if s.BackColor == clr do
	(
		(s.BackColor = ClrBG)
		pxc = getPixClr()
		pixClr.BackColor = defColor pxc.r pxc.g pxc.b
		clock.Stop()
		setSelectFilter sfIdx
	)
)
fn clockTick s e =
(
	pxc = getPixClr()
	pixClr.BackColor = defColor pxc.r pxc.g pxc.b
)
dotnet.addEventHandler clock "Tick" clockTick
dotnet.addEventHandler pickBtn "Click" buttonClick
dotnet.addEventHandler pickBtn "LostFocus" butonLF
registerSF()
form.Controls.AddRange #(pickBtn,pixClr)
form.showmodeless() ; ok
)

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.