In 3ds Max 2019 dotnet.addEventHandler not works when it is inside Struct.
Here is my test code:
(
struct miauuRCMenu
(
function GrpNameColor s e =
(
print "GrpNameColor"
local bgcolor = ((dotNetClass "System.Drawing.Color").FromArgb 86 86 86)
bb = dotnetobject "System.Drawing.SolidBrush" (s.Backcolor = bgcolor)
fb = dotnetobject "System.Drawing.SolidBrush" s.Forecolor.white
dnFontStyle = dotNetClass "System.Drawing.FontStyle"
myFontStyle = dotnet.combineEnums dnFontStyle.regular
font = dotNetObject "System.Drawing.Font" "Arial" 9 myFontStyle
r = e.ClipRectangle
e.Graphics.FillRectangle bb r
sf = dotnetobject "System.Drawing.StringFormat"
sf.LineAlignment = (dotnetclass "System.Drawing.StringAlignment").Center
rect = dotnetobject "System.Drawing.RectangleF" (r.x+23) r.y (r.width-34) r.height
e.Graphics.DrawString s.Text font fb rect sf
),
function RCEntry_01 sender args =
(
print "RCEntry_01"
),
function RCEntry_02 sender args =
(
print "RCEntry_02"
),
function RCEntry_03 sender args =
(
print "RCEntry_03"
),
function Closed e =
(
print "Closed"
),
dotNetRCSeparator01 = (dotNetObject "System.Windows.Forms.ToolStripSeparator"),
function DotNetRCMenu =
(
print "DotNetRCMenu"
rcMenuPos = mouse.screenpos
contextMenu = dotNetObject "System.Windows.Forms.ContextMenuStrip"
contextMenu.ForeColor = (dotNetClass "System.Drawing.Color").white
contextMenu.BackColor = (dotNetClass "System.Drawing.Color").gray
dotnet.addEventHandler contextMenu "Closed" Closed
cmGrpName01 = contextMenu.Items.Add "NEW GROUP 01"
dotnet.addEventHandler cmGrpName01 "Paint" GrpNameColor
cmRCEntry_01 = contextMenu.Items.Add "RCEntry_01"
dotnet.addEventHandler cmRCEntry_01 "Click" RCEntry_01
cmRCEntry_02 = contextMenu.Items.Add "RCEntry_02"
dotnet.addEventHandler cmRCEntry_02 "Click" RCEntry_02
contextMenu.Items.Add dotNetRCSeparator01
cmGrpName02 = contextMenu.Items.Add "NEW GROUP 02"
dotnet.addEventHandler cmGrpName02 "Paint" GrpNameColor
cmRCEntry_03 = contextMenu.Items.Add "RCEntry_03"
dotnet.addEventHandler cmRCEntry_03 "Click" RCEntry_03
contextMenu.Show rcMenuPos[1] rcMenuPos[2]
)
)
global miauuStrRCMenu = miauuRCMenu()
miauuStrRCMenu.DotNetRCMenu()
)
When I run it in 3ds Max 2014 the RC menu looks this way:

When I run it in 3ds Max 2019 it looks this way:

Click on RCEntry_01, _02, _03 must print text in the MaxScript Listener, but this not happens in 3ds max 2019, althou it works properly in 3ds Max 2014.
I have found this thread and the code from denisT also not works in 3ds Max 2019, but works in previous versions of 3ds Max.
try (destroydialog testRollout ) catch()
rollout testRollout "testRollout" width:664 height:60
(
struct charData
(
b = dotnetobject "button",
storedNodes,
fn printAry sender arg =
(
print sender.tag.value.storedNodes
),
on create do
(
b.tag = dotnetmxsvalue this
dotnet.addEventHandler b "mouseDown" printAry
)
)
fn AddFlowLayoutNodes control =
(
for i = 1 to 6 do
(
p = dotnetobject "flowlayoutpanel"
p.size = dotnetobject "System.Drawing.Size" 100 40
p.backcolor = p.backcolor.DarkGray
control.Controls.add p
newLimb = charData storedNodes:i
-- print newLimb.storedNodes
newLimb.b.text = ("Button: " + (i as string))
p.controls.add newLimb.b
if i == 6 do (return p)
)
)
dotNetControl flp "flowlayoutpanel" pos:[2,4] width:654 height:50
on testRollout open do
(
flp.borderstyle = flp.borderstyle.fixedsingle
flp.autoscroll = true
flp.SuspendLayout()
flp.setflowbreak (AddFlowLayoutNodes flp) true
flp.resumelayout()
)
)
createdialog testRollout