Re: Getting mouse cursor position
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