I have a type
type figure =
{
what : int;
position : Point;
size : Point;
}
and i want my function to return this type, however since it’s an event it wants to return a unit ()
how can i get my function to return this type instead of unit?
let checkInput =
drawArea.MouseClick.Add(fun args ->
if args.Button = MouseButtons.Left then
new figure { what = 0; position = new Point(args.X, args.Y); size = new Point(50, 50) })
any help on this would be appreciated
In your example the compiler doesn’t know what to do with the new figure you created. Figure needs to be stored somewhere or passed to a function. Here’s an example where it’s passed to a function. When you click in the form the title is updated to the clicked position.
You will need to include these two assemblies under references in your project for this example.