I have a question about Dotnet form focus


#1

(
tform=dotNetObject “MaxCustomControls.MaxForm”
InputBox2=dotNetObject “System.windows.forms.TextBox”

Btn2 = dotNetObject “System.windows.forms.button”
Btn2.Location=dotnetobject “System.Drawing.Point” 100 100

fn do_nothing=(InputBox2.focus())

tForm.controls.add InputBox2
tForm.controls.add Btn2
dotnet.addEventHandler Btn2 “Click” do_nothing

tForm.showmodeless()
InputBox2.Focus()
)

My code looks like this

in this situation, if the user moves out of tForm to another window ( Like Max’s Viewport)
I will run this
“function close_form= tForm.close()”

What should I do?


#2

this is usually handled by an event, there should be an event called LostFocus

you can find all the events in maxscript manual
https://help.autodesk.com/view/3DSMAX/2017/ENU/?guid=__files_GUID_C1301180_A6AC_48F2_AD8E_9D7EA16D359A_htm

this will probably look like
on tForm lostfocus e do tForm.close()