#delegate type fn
Creates a delegate, of type type
, with the monadic function fn
as the handler. The delegate can then be attached to a .Net event handler. For example (from gui.rws):
b←#new $Button []; b:Text←"Press me!"; b_onClick←{⍇(⍵⌷1):Text}; b:Click←#delegate $EventHandler b_onClick;
All the parameters passed to the delegate are passed to your handler function in the right argument, which is an n-element vector where n is the number of parameters in the delegate's declaration. For example, in this case System.EventHandler takes (object, System.EventArgs) so ⍵
is a 2-element vector. If the delegate expects a result, the value returned from your event handler is used; you need to make sure it is the correct type.
Most delegate definitions in System.Windows.Forms take (object, EA) where EA is some sort of EventArgs structure. For details on individual delegate signatures, see the Framework documentation.
Limitation: you cannot assign to a ref parameter from a Rowan event handler.
The ArgumentException is thrown if type
is not a delegate type. The ContextException is thrown if fn
is not monadic.