Notifications
Clear all

[Closed] dotnet, Pick Button

hi!
i have just started learning how to integrate dotnet and max (so forgive the naiviness of the question!) , i am creating a simple node selection dialog using dotnet (for a utility), the node selection dialog offers the user to pick a node, select the node by name, or use the currently selected node. the node selection dialog is a simple dotnet form object which contains a list box to show the details of the selected node and a bunch of buttons to facilitate node selection. i have added a dotnet handler for my pick button which executes the following code on click:


	fn on__PickButton__Click = 
	(		
		fn geometryFilter obj = superclassof obj == GeometryClass
		geo_objs = pickobject filter:geometryFilter forcelistenerfocus:false count:2
		try
		(
			for i in geo_objs do
				print i.name
		)
		catch()
	)

the problem is the user has to click twice to select a node (first to give max focus and second to actually select the node) how can i fix this (i.e how do i give the active viewport focus when the pick button is clicked)?
also i have set my form as the topmost window since i do not want it to be minimized when the user clicks on the viewport to pick a node (is it possible to penetrate mouse events through the dot net form? this way i could set my dialog to 30% opacity when the pick button is pressed and any node behind the dialog box could be picked, or maybe minimize the form when the pick button is clicked then restore the form when the node is picked)

thanks!

6 Replies

you are asking for 2 picks


 pickobject filter:geometryFilter forcelistenerfocus:false count:2
 

you can’t pick an object in max viewport behind opaque or semitransparent window.

thanks for the post!

you are asking for 2 picks

If i remove the count parameter it takes 2 clicks (1 click is wasted for giving max focus, irrespective) the mouse pointer does not change to cross-hair until max gets focus ofcourse (even if i am hovering over geometry object)

thanks!



try(form.close()) catch()
(
	form = dotnetobject "MaxCustomControls.Maxform"
	form.StartPosition = form.StartPosition.Manual
	form.size = dotnetobject "System.Drawing.Size" 220 70
	form.location = dotnetobject "System.Drawing.Point" 500 200

	pbt = dotnetobject "RadioButton"
	pbt.text = "Pick Object"
	pbt.Appearance = pbt.Appearance.Button
	pbt.FlatStyle = pbt.FlatStyle.Flat
	pbt.FlatAppearance.CheckedBackColor = pbt.FlatAppearance.CheckedBackColor.Orange

	pbt.Dock = pbt.Dock.Top	

	fn CheckedChanged s a = if s.Checked do
	(
		if isvalidnode (obj = pickObject()) do s.text = obj.name 
		s.Checked = off
	)	
	dotNet.addEventHandler pbt "CheckedChanged" CheckedChanged
	form.controls.add pbt

	form.showmodeless()
)

does it need more then one click for you?

does it need more then one click for you?

thanks, the script works . the culprit was the forcelistenerfocus parameter.

  pickobject filter:geometryFilter forcelistenerfocus:false count:2

oh, and nice trick with the check box

thanks!

1 click is wasted for giving max focus, irrespective

Not true!

If you run your tool using the max handle pointer, the tool already has max focus and counts as a part of Max from the perspective of the operating system (which means it doesn’t have the overlapping problems that normal dotNet tools do).

It is a very handy trick.

--Get the max handle pointer.
maxHandlePointer=(Windows.GetMAXHWND())

--Convert the HWND handle of Max to a dotNet system pointer
sysPointer = DotNetObject "System.IntPtr" maxHandlePointer

--Create a dotNet wrapper containing the maxHWND
maxHwnd = DotNetObject "MaxCustomControls.Win32HandleWrapper" sysPointer

--Show the Max form using the wrapper. 
m_tool.Show(maxHwnd)
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it’s the exactly same as
showmodeless()