• 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 the position of the mouse
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the position of the mouse


  • Subject: Re: Getting the position of the mouse
  • From: Cristi Savu <email@hidden>
  • Date: Fri, 15 Nov 2002 10:20:08 +0200

No, it's not that simple !
Look what I'm trying to do :
- I'm popping up a menu at mouseDown on a view.
- if the user pressed ESCAPE, the menu disappears but since that moment, my beloved view doesn't receive
mouseMoved events anymore. So, I need to make it first responder again only if the mouse is still inside.
- Because of that, I'm capturing keyUp, and I'm performing my first responder mambo-jambo in there.
- this is the code, if anybody has a slightest idea, please let me know.

(BTW, not receiving mouseMoved anymore after a context menu is dismissed is a cocoa bug, if anybody from there reads this)

- (void)keyUp:(NSEvent *)theEvent
{

NSString * tString;
unichar tChar;
tString= [theEvent characters];
NSLog(@"Key pressed");
tChar=[tString characterAtIndex:0];
if (tChar == 27)
{
NSPoint clickPoint = [theEvent locationInWindow];
NSPoint aPoint = [self convertPoint:clickPoint fromView:nil];

NSLog(@" Escape Pressed ! The mouse is at : %f, %f",clickPoint.x, clickPoint.y); // NOPE IT IS NOT,
// clickPoint contains the origin of my window

// main window is first respoder
[[self window] setAcceptsMouseMovedEvents: NO];
[[self window] makeFirstResponder:[self window]];

// NEVER INSIDE
if (NSPointInRect(aPoint, [self bounds]))
{
NSLog(@"Escape Pressed ! AND THE MOUSE IS INSIDE");
// my view is first respoder
[[self window] setAcceptsMouseMovedEvents: YES];
[[self window] makeFirstResponder:self];
}
// else
// NSLog(@" Escape Pressed ! AND THE MOUSE IS OUTSIDE");
}
[[self window] resetCursorRects];
[[self window] invalidateCursorRectsForView:self];

}
On Friday, November 15, 2002, at 09:36 AM, Charles Srstka wrote:

I think it's [[NSApp currentEvent] mouseLocation];

HTH,
Charles

On Thursday, November 14, 2002, at 04:45 AM, Cristi Savu wrote:

How can I get the position of the mouse at any time in an application ?
I need to know the position of the mouse while I am inside keyUp of keyDown and
the event received by these methods doesn't contains a valid mouse position.

Regards, Cristian
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Getting the position of the mouse
      • From: Marco Binder <email@hidden>
References: 
 >Re: Getting the position of the mouse (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Getting the position of the mouse
  • Next by Date: Re: TableColumn dataCell actions
  • Previous by thread: Re: Getting the position of the mouse
  • Next by thread: Re: Getting the position of the mouse
  • Index(es):
    • Date
    • Thread