4

A peculiar issue is popping up with regards to global monitoring of modifier flag changes.

Assume the monitor is as below...

_flagsChangedGlobalEventHandler = [NSEvent addGlobalMonitorForEventsMatchingMask:NSFlagsChangedMask
handler:^(NSEvent *event) {

    NSLog(@"Global flags changed event");

    NSLog(@"[NSEvent modifierFlags] is %i and [event modifierFlags] is %i",
          [NSEvent modifierFlags], [event modifierFlags]);
}

Initially, the log provides the following when pressing left Command:

[NSEvent modifierFlags] is 1048576 and [event modifierFlags] is 1048840

and after releasing left Command:

[NSEvent modifierFlags] is 0 and [event modifierFlags] is 256

Now, after I move a window on my MacBook using the three finger hold on the title bar area, the following results from the same monitor:

[NSEvent modifierFlags] is 1048576 and [event modifierFlags] is 1048584

and after releasing left Command: [NSEvent modifierFlags] is 0 and [event modifierFlags] is 0

The questions:

  1. Why is it that [event modifierFlags] returns different values, in particular 256 for when no modifier is held?

  2. Why is it that the three finger window move gesture causes the [event modifierFlags] to change by -256?

I gather it may have something to do with caps lock, though I'm not sure why the class and ivar modifierFlags return different results.

I'm on 10.7.3.

the979kid
  • 635
  • 5
  • 15
  • Never mind - this one explains it! http://stackoverflow.com/questions/6084266/check-modifierflags-of-nsevent-if-a-certain-modifier-was-pressed-but-no-other – the979kid Mar 07 '12 at 13:49
  • That's funny -- I was all set to answer until I saw your comment linking to another answer of mine! – jscs Mar 07 '12 at 19:55

0 Answers0