ScriptSpot

Forum topic · General Scripting

event handler for a custom thumbnails

By zahid hasan · 2024-10-18

Description

Hi,

I need help with a dot-net. My frirnd and I are making a custom library image browser using dot-net in max rollout. The thumbnails are showing properly using/loading custom dot-net controls. But we cannot managed to set an event handler when clicking a thumb. we want something like
"on small_dialog clicked sender arg do ()". But the click makes no change

do we need to make an new event and make it public from dot-net? I attached the code and dll as well and a screenshot.

I know partial max-script and he knows moderate dot-net. together we are almost disastrous.

Attachments
Comments (3)

Hi,

SimonBourgeois · 2024-10-18

Here are some example for dotnet button click event.
For a classic maxscript rollout:


(
	rollout testRollout "Test Rollout" width:300 height:300
	(
		dotNetControl testBtn "System.Windows.Forms.Button" pos:[75,75] width:150 height:150
		
		on testRollout open do
		(
			testBtn.text = "Click Me"
		)
		on testBtn click do --use click instead of pressed ;)
		(
			print "button clicked"
		)
	)
createDialog testRollout
)

For a dotnet windows:


(
	fn onButtonPressed Sender arg =
	(
		print "button clicked"
	)
	testBtn = dotNetObject "System.Windows.Forms.Button"
	testBtn.text = "Click Me"
	testBtn.size = dotNetObject "System.Drawing.Size" 150 150
	testBtn.location = dotNetObject "System.Drawing.Point" 75 75
	testForm = dotNetObject "System.Windows.Forms.Form"
	testForm.size = dotNetObject "System.Drawing.Size" 300 300
	testForm.controls.add testBtn
	testForm.topmost = true
	dotNet.addEventHandler testBtn "click" onButtonPressed
	testForm.show()
)

zahid hasan · 2024-10-19

Thank you a lot.

you're welcome

SimonBourgeois · 2024-10-20

:)