• 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
locationInWindow not valid for key event (as opposed to mouse event)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

locationInWindow not valid for key event (as opposed to mouse event)?


  • Subject: locationInWindow not valid for key event (as opposed to mouse event)?
  • From: "Michael B. Johnson" <email@hidden>
  • Date: Sat, 5 Jan 2002 23:45:25 -0800

So at first I thought this was me, but after looking at the doc more closely, and the NSEvent header file, I think this is a bug (or I'm missing something obvious - which is what I hope :-))

I have a view that a user will be doing some mouseDown:/mouseDragged:/mouseUp: interaction in, and there are a variety of modifiers that they might use (i.e. option for translate, shift for zoom, etc.) I want to make this as seamless as possible, which means that I want the user to be able to change modifiers in mid mouseDown. For example, if they're translating holding the mouse and the shift and they want to zoom in a bit, they should be able to let up on the shift key and press down on the option without having to think about also letting up on the mouse and then pressing it again.

So it seems to me that the best bet is to catch flagsChanged: and essentially call the same code I call in mouseUp/mouseDown to stop one mode and start another. Unfortunately, I need the location of the mouse in the window, which seems to be garbage in the case of the key event I get in flagsChanged:, while it's great in the mouseUp:/mouseDown:. Actually, it never changes in the flagsChanged: one - I get a trace like this:

2002-01-05 23:33:07.334 PickTest[384] continuing rotate at 226.000000 180.000000 in window <NSWindow: 0x2f0d70>:
2002-01-05 23:33:07.350 PickTest[384] continuing rotate at 220.000000 181.000000 in window <NSWindow: 0x2f0d70>:
2002-01-05 23:33:07.383 PickTest[384] continuing rotate at 218.000000 181.000000 in window <NSWindow: 0x2f0d70>:
2002-01-05 23:33:07.396 PickTest[384] continuing rotate at 216.000000 183.000000 in window <NSWindow: 0x2f0d70>:
2002-01-05 23:33:07.728 PickTest[384] flags changed at -558.000000 413.000000 in window <NSWindow: 0x2f0d70>:

I can move the mouse all over the view, and every time I change which modifier key I'm holding down, the location is the *same* (and it always seems to be some negative X). As you can see from the trace, the window is the same for the mouse and key events, so it's not like that's the issue.

According to the header, I think what I'm doing should work:

/* these messages are valid for all events */
- (NSPoint)locationInWindow;
- (unsigned int)modifierFlags;
- (NSWindow *)window;

Any ideas? I'm stumped...


--> Michael B. Johnson, Ph.D. -- email@hidden
--> Studio Tools, Pixar Animation Studios
--> http://xenia.media.mit.edu/~wave


  • Prev by Date: Re: Apple's Address Book File Format
  • Next by Date: After awakeFromNib and beyond applicationDidFinishLaunching (but just a little)
  • Previous by thread: NSWindow tiers
  • Next by thread: After awakeFromNib and beyond applicationDidFinishLaunching (but just a little)
  • Index(es):
    • Date
    • Thread