View Full Version : Wacky mod panel scope issues?
So I have a tool that I'm launching from a scripted modifier. What I have is a struct based tool that creates and launches a dotNet form with items with event handlers. A function of the struct is called from a button in the modifier and passed a couple of string values as params.
theStruct.run someString someOtherString
The event handlers are not working in the dotNet ui and I gather it is a scope issue. If I call the run function manually and pass it the needed strings that are stored in the modifier it works as it should. But if the button is pressed in the modifier and the same lines are called the UI gets built as it should but the event handlers will not fire.
Any solutions to this?
The struct is global by the way.
Isn't there an issue with event handlers and scripted modifiers in general, in that they don't work together at all... I'm not completely sure, but I fear the worst.
I think this http://forums.cgsociety.org/showthread.php?f=98&t=773415 is the same problem and no solution there either. I hope I'm wrong!
Paul, have to set the dotNet controls' lifetime control to #dotnet via dotNet.setLifetimeControl as described in the topic "DotNet Objects and Classes Life Time Control" in the MAXScript Reference 2010 and higher?
This isn't a setLifeTimeControl issue as I am setting that. JHN, that is the same problem and I remember that thread now. I think that I even played around with it and tried to get it to work.
It is very strange that the plugin is just calling the struct and it doesn't work. It is one line of code and no matter how I try and fire the tool off from the plugin it will not work.
11-30-2010, 08:05 PM
any dotnet window (control) created from mxs plug-in eats its own events. only way that I found is to call the popup dialog not from plugin but using external dotnet timer:
label = "",
pos = dotnetobject "System.Drawing.Point" 200 200,
size = dotnetobject "System.Drawing.Size" 200 100,
fn onWindowActive s e =
format "active: % %\n" s s.visible
fn onWindowClose s e =
format "close: %\n" s
fn create =
fn buttonPressed s e =
format "pressed: %\n" s
form = s = dotnetobject "MaxCustomControls.MaxForm"
b = dotnetobject "Button"
b.text = "Click Me"
b.dock = b.dock.Top
s.text = label
s.StartPosition = s.StartPosition.Manual
s.Location = pos
s.Size = size
dotnet.addEventHandler b "MouseClick" buttonPressed
dotnet.addEventHandler s "Shown" onWindowActive
dotnet.addEventHandler s "Closed" onWindowClose
fn show = if iskindof form dotnetobject do
global PopupTimer = dotnetobject "Timer"
fn onTimerTick s e =
format "timer:\n" s
if s.tag != undefined do
dotnet.addEventHandler PopupTimer "Tick" onTimerTick
plugin modifier EmptyExtends
rollout params "Parameters"
button bt "Popup Dotnet" width:150
on bt pressed do
data = PluginPopup()
data.label = "Win_" + ((GetHandleByAnim this) as string)
data.pos = dotnetobject "System.Drawing.Point" (random 100 1000) 200
PopupTimer.tag = dotnetMXSvalue data
in this case all events are valid and all controls fire their events. it's easy to organize the uniqueness of popup dialogs, checking popup dialog state, initialization, passing params from plug-in, storing data on close events, etc.
the popup dialog structure and timer-launcher are defined in the same as plug-in's code file and loads with max. One GLOBAL timer launches all plug-in's pop-ups.
on "Popup Dotnet" button pressed I don't check the state of the popup dialog. This is not because I don't know how, it's just because I don't care. :)
11-30-2010, 08:05 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.