Notifications
Clear all
[Closed] Custom attributes .net events
Apr 27, 2014 9:46 pm
Hi,
whenever I try to add event handlers to wpf controls that are defined in a custom attribute the events are not catched.
For example this works:
(
rollout rol "rol"
(
dotNetControl eh "Integration.ElementHost" width:50 height:20
fn a = print "Clicked!"
on rol open do
(
but = dotNetObject "System.Windows.Controls.Button"
but.content = "Press me"
eh.child = but
dotnet.addeventhandler but "Click" a
)
)
createDialog rol
)
but if I put it inside a custom attribute def nothing happens:
(
custAttributes.add (box()) (a = attributes test
(
rollout rol "rol"
(
dotNetControl eh "Integration.ElementHost" width:50 height:20
fn a = print "Clicked!"
on rol open do
(
but = dotNetObject "System.Windows.Controls.Button"
but.content = "Press me"
eh.child = but
dotnet.addeventhandler but "Click" a
)
)
)
)
)
What am I missing?
5 Replies
1 Reply
Apr 27, 2014 9:46 pm
(
custAttributes.add (box()) (a = attributes test
(
rollout rol "rol"
(
--dotNetControl eh "Integration.ElementHost" width:50 height:20
dotnetControl sysButt "button"
fn a = print "Clicked!"
on rol open do
(
sysButt.Text="aa"
--but = dotNetObject "System.Windows.Controls.Button"
--but.content = "Press me"
--eh.child = but
--dotnet.addeventhandler sysButt "Click" a
)
on sysButt mouseUp senderArg arg do
(
if arg.button==arg.button.left then
(
print "aaaa"
)
)
)
)
)
)
Apr 27, 2014 9:46 pm
(
custAttributes.add (box()) (a = attributes test
(
rollout rol "rol"
(
--dotNetControl eh "Integration.ElementHost" width:50 height:20
dotnetControl sysButt "button"
fn a = print "Clicked!"
on rol open do
(
sysButt.Text="aa"
--but = dotNetObject "System.Windows.Controls.Button"
--but.content = "Press me"
--eh.child = but
--dotnet.addeventhandler sysButt "Click" a
)
on sysButt mouseUp senderArg arg do
(
if arg.button==arg.button.left then
(
print "aaaa"
)
)
)
)
)
)
Apr 27, 2014 9:46 pm
Thanks, but it’s not what im after. My gui is a wpf control, hence the elementhost control.
Apr 27, 2014 9:46 pm
Thanks. I ended up running the intended maxscript event code from my wpf control instead.