• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting mouse cursor position
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting mouse cursor position


  • Subject: Re: Getting mouse cursor position
  • From: Nick <email@hidden>
  • Date: Sat, 07 May 2011 20:28:13 +0300

2011/5/7 Gregory Weston <email@hidden>:
> eveningnick wrote:
>
>> Hello
>> I am searching for the way to find a cursor's position on the screen.
>>
>> I tried to use method -hotSpot of NSCursor, but it returns
>>> sc x=-2057825613, y=0
>>
>>
>> -(IBAction)timeHandler:(id)timer {
>>        //NSCursor *sc = [NSCursor currentSystemCursor];
>>       NSCursor *sc = [NSCursor currentCursor];
>>       NSLog(@"sc x=%d, y=%d", [sc hotSpot].x, [sc hotSpot].y);
>> }
>>
>> What may be wrong here?
>> I can successfully retrieve cursor's image though. But not the position. Why?
>
> Aside from the fact that you're treating it as the wrong data type, as has been pointed out, this is not the right method for your goal. The hotSpot method returns the location of the point within the cursor image that represents where the mouse is onscreen. Effectively it controls where the 2D image of the cursor is drawn relative to the point that is the mouse's current location.
>
> What you want is NSWindow's mouseLocationOutsideOfEventStream. Or preferably, if you have an event, then NSEvent's mouseLocation.

Gregory,
what do you mean by "if you have an event"? Could you elaborate on it please?

> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Getting mouse cursor position
      • From: Gregory Weston <email@hidden>
    • Re: Getting mouse cursor position
      • From: Andy Lee <email@hidden>
References: 
 >Re: Getting mouse cursor position (From: Gregory Weston <email@hidden>)

  • Prev by Date: A Simple and Complete RunLoop Example
  • Next by Date: Re: Getting mouse cursor position
  • Previous by thread: Re: Getting mouse cursor position
  • Next by thread: Re: Getting mouse cursor position
  • Index(es):
    • Date
    • Thread