grabjacket
06-11-2009, 03:06 PM
Hi,
Once again I'm having trouble with .NET controls losing event handlers.
I've got a scripted material. This material has got a button to launch a dialog. In this dialog the user can pick different textures. When doubleclicking a texture in the dialog, the texture is loaded back into the material and the form closes. At least, that's the idea.
I've got my scripted material working fine, and the external dialog works fine too. It's a .NET form with .NET controls. Since it uses listviews and drag&drop I can't code it back to normal max controls.
The problem: I can launch the dialog from the scripted material but the controls on that dialog don't react. I don't know if there's a problem with the event handlers or if it's a scoping issue. The example should demonstrate the problem (made in max2008 64bit). Could someone help me?
plugin material fileInShader
name:"fileInShader"
classID:#(0x7b6be4e2, 0x761ff1e6)--has to be unique, use genClassID() to generate an ID
extends:standard
replaceUI:true
version:1
(
struct maxFormStruct
(
theForm,
theButton,
function fn_declare =
(
theForm = dotNetObject "MaxCustomControls.MaxForm"
theButton = dotNetObject "button"
),
--define and construct the form
function fn_init =
(
--button
theButton.Dock = theButton.Dock.fill
theButton.text = "Press me to print stuff"
--maxform
theForm.Size = dotNetObject "System.Drawing.Size" 400 200
theForm.Text = ".NET form"
theForm.controls.add theButton
),
function event_printStuff = print "stuff",
declare = fn_declare(),
init = fn_init(),
handler = dotNet.addEventHandler theButton "mouseClick" event_printStuff,
show = theForm.ShowModeless()
)
rollout rollTest "Test if other dialogs with .NET controls work"
(
button btnLaunch "Launch dialog"
on btnLaunch pressed do maxFormStruct()--launch the .NET form
)
)
Once again I'm having trouble with .NET controls losing event handlers.
I've got a scripted material. This material has got a button to launch a dialog. In this dialog the user can pick different textures. When doubleclicking a texture in the dialog, the texture is loaded back into the material and the form closes. At least, that's the idea.
I've got my scripted material working fine, and the external dialog works fine too. It's a .NET form with .NET controls. Since it uses listviews and drag&drop I can't code it back to normal max controls.
The problem: I can launch the dialog from the scripted material but the controls on that dialog don't react. I don't know if there's a problem with the event handlers or if it's a scoping issue. The example should demonstrate the problem (made in max2008 64bit). Could someone help me?
plugin material fileInShader
name:"fileInShader"
classID:#(0x7b6be4e2, 0x761ff1e6)--has to be unique, use genClassID() to generate an ID
extends:standard
replaceUI:true
version:1
(
struct maxFormStruct
(
theForm,
theButton,
function fn_declare =
(
theForm = dotNetObject "MaxCustomControls.MaxForm"
theButton = dotNetObject "button"
),
--define and construct the form
function fn_init =
(
--button
theButton.Dock = theButton.Dock.fill
theButton.text = "Press me to print stuff"
--maxform
theForm.Size = dotNetObject "System.Drawing.Size" 400 200
theForm.Text = ".NET form"
theForm.controls.add theButton
),
function event_printStuff = print "stuff",
declare = fn_declare(),
init = fn_init(),
handler = dotNet.addEventHandler theButton "mouseClick" event_printStuff,
show = theForm.ShowModeless()
)
rollout rollTest "Test if other dialogs with .NET controls work"
(
button btnLaunch "Launch dialog"
on btnLaunch pressed do maxFormStruct()--launch the .NET form
)
)
