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:
Why is it that [event modifierFlags] returns different values, in particular 256 for when no modifier is held?
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.