Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6991217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:28:05+00:00 2026-05-27T19:28:05+00:00

I have a type type figure = { what : int; position : Point;

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:28:06+00:00Added an answer on May 27, 2026 at 7:28 pm

    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.

    open System.Drawing
    open System.Windows.Forms
    
    type Figure = {
       what : int;
       position : Point;
       size : Point;
    }
    
    let drawArea = new Form()
    
    let print figure =
        drawArea.Text <- figure.position.ToString()
    
    drawArea.MouseClick.Add(fun args -> 
        if args.Button = MouseButtons.Left then 
            print { what = 0; position = Point(args.X, args.Y); size = Point(50) }
    )
    
    Application.Run(drawArea)
    

    You will need to include these two assemblies under references in your project for this example.

    System.Drawing
    System.Windows.Forms
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code fails in 'Evaluate' with: This expression was expected to have type
Can't seem to figure this one out. I have a web service defined as
I keep getting this error - error C2819: type 'List' does not have an
I have an (int * string) tuple which I want to covert into a
I have an array with Field Names and jdbc Type codes. (Those int codes
I want to have a map that has a homogeneous key type but heterogeneous
I have another error, unexpected type required:variable found:value and I can't figure out why.
Suppose this is what I have in my database table Ancestor ( idAncestor int
Suppose I have this class: type Pet (name:string) as this = let mutable age
I have the following problem: template <int N, typename T> /*what is the return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.