Label Events

hi, i need to add event (mouse click/right click) to label (dotNet label on rollout) using dot net and max script (cause max script alone dont have label events).
Any code would be great ;)

Comments

Comment viewing options

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

THANK YOU ! Its working great

THANK YOU ! Its working great :)

barigazy's picture

...

As you saw it's very easy to mimic "button" functionality with simple .net control.

bga

barigazy's picture

...

You can do it this way

try(destroyDialog ::bgaRoll)catch()
rollout bgaRoll "• • •"
(
	fn defColor r g b = (dotNetClass "System.Drawing.Color").FromArgb r g b
	fn defFontB fName fSize = (dotNetObject "System.Drawing.Font" fName fSize ((dotNetClass "System.Drawing.FontStyle").bold))
	fn defFontR fName fSize = (dotNetObject "System.Drawing.Font" fName fSize ((dotNetClass "System.Drawing.FontStyle").regular))
	local maxBC = (colorMan.getColor #background) * 255.
	local maxFC = (colorMan.getColor #Text) * 255.
	local colorA = (defColor maxFC.x maxFC.y maxFC.z), colorB = (defColor maxBC.x maxBC.y maxBC.z), colorC = defColor 150 10 10, colorD = defColor 255 128 0
	local fontA = (defFontB "Verdana" 8) , fontB = (defFontR "Tahoma" 10)
 
	fn defLbl dnLbl txt: bClr: fClr: font: =
	(
		if font != unsupplied do dnLbl.font = font
		dnLbl.Text = txt ; dnLbl.BackColor = bClr ; dnLbl.ForeColor = fClr
		dnLbl.TextAlign = dnLbl.TextAlign.MiddleCenter
	)
	dotnetcontrol lbl1 "Label" pos:[2,2] width:196 height:22
	dotnetcontrol lbl2 "Label" pos:[2,25] width:196 height:22
 
	on lbl1 mouseup arg do 
	(
		case arg.Button of 
		(
			(arg.Button.Left): print "GrayLabel_LMB"
			(arg.Button.Middle): print "GrayLabel_MMB"
			(arg.Button.Right): print "GrayLabel_RMB"
		)
	)
	on lbl2 mouseup arg do 
	(
		case arg.Button of 
		(
			(arg.Button.Left): print "RedLabel_LMB"
			(arg.Button.Middle): print "RedLabel_MMB"
			(arg.Button.Right): print "RedLabel_RMB"
		)
	)
	on bgaRoll open do 
	(
		defLbl lbl1 txt:"Gray Label" bClr:colorA fClr:colorB font:fontA
		defLbl lbl2 txt:"Red Label" bClr:colorC fClr:colorD font:fontB
	)
 
)
createDialog bgaRoll 200 47 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

bga

Comment viewing options

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