canvas.MouseMove.Add(move canvas update)
MouseMove.Add( p1 p2 p3)
Usually I see this use and documentation, two params -- (object sender, MouseEventArgs e) -- which I take to be move and canvas in this example code, taken from F#.NET Journal's Computational geometry: quick hull.
Is update some delagate? or routing bubble info to MouseMove.Add?
I'm just not gettng it. Any help welcome. Thanks. Art
The answer from kvb gives all the theory, so I thought I could also add a code sample. I don't know the source of the snippet, so I'll make some guesses based on the names - hopefully it will be useful even if it may not be completely same as the original sample.
As kvb says, the code
move canvas update
is actually a function call that returns a function, which is then added as a handler to theMouseMove
event.This means that
move
could be declared as follows:When registering the event handler, the code
move canvas update
specifies the first two arguments of themove
function, so that the handler can accesscanvas
value that was probably declared in the place where the handler is registered (without the use of mutable variables!)This should also explain why the event handler does not need to take
sender:object
as the first argument - you can pass thecanvas
(which is the sender) as a first argument using partial function application in a statically typed way (so you don't have to castobject
toCanvas
).