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 6964407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:55:14+00:00 2026-05-27T15:55:14+00:00

I have a custom view class, which receives the mouse events. I do not

  • 0

I have a custom view class, which receives the mouse events. I do not get correct coordinates of the mouseDown or mouseUp events. No matter where I click inside the view, I get the same incorrect coordinates.

This is the function I have in my Custom NSView class

- (void)mouseDown:(NSEvent *)theEvent
{
    NSPoint coordinateInBaseWindow = theEvent.locationInWindow;
    
    NSPoint coordinateInView = [self convertPoint:coordinateInBaseWindow fromView:nil];
    NSLog(@"left mouse down (x,y) =(%f,%f)", coordinateInView.x, coordinateInView.y);
}

I have a similar handler of mouseUp event.

Now the output is always

left mouse down (x,y) =(0.000000,-1.996910)

left mouse up (x,y) =(0.000000,0.000000)

No matter where I click inside the view, the coordinate of left mouse down is always (0.000000,-1.996910) and left mouse up is always (0.000000,0.000000).

  1. What am I doing wrong? Why I am unable to get correct coordinates of the mouse click event?
  2. mouseDown and mouseUp together makes one click. Shouldn’t the coordinates of the mouseDown and mouseUp equal? Why are they different in this case?

Edit 1:

As omz pointed out, I should have used convertPoint:fromView: but this too has not solved the problem. I am still getting the same coordinates.

Edit 2:
My format specifiers in NSLog were incorrect which were giving me totally wrong results.

  • 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-27T15:55:15+00:00Added an answer on May 27, 2026 at 3:55 pm

    To convert from window coordinates you have to use convertPoint:fromView: with nil as the view parameter. Your conversion does the opposite.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom view class which is a subclass of UITableViewCell. I have
I have a custom model class which contains a decimal member and a view
i have a custom tabBar class in which i switch three view controllers ,i
i have created a custom view class which is a subclass of UIview class
I have a custom-made view that extends the View class. I would like 2
I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and
I have a GridView in which each row has a custom view. The grid
I have a custom component which consists of 2 text view and 4 toggle
HI have a custom view class that is loaded and placed within my main
I have a custom view to which I need to add a couple of

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.