Mercurial > osx-quasimode
annotate TestQuasimodalEventTap.m @ 24:f2f634d576cf
quasimodal events now propogate to JS.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Mon, 12 Apr 2010 01:40:16 -0700 |
parents | ddc7cc16c48c |
children | c3e5b6b3bb4b |
rev | line source |
---|---|
21
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
1 #import <Foundation/NSString.h> |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
2 #import <Foundation/NSKeyValueCoding.h> |
19
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
3 #import <Foundation/NSAutoreleasePool.h> |
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
4 |
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
5 #import "QuasimodalEventTap.h" |
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
6 |
21
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
7 @interface TestObserver : NSObject { |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
8 } |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
9 - onEvent:(NSNotification *)notification; |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
10 @end |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
11 |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
12 @implementation TestObserver |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
13 - onEvent:(NSNotification *)notification { |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
14 NSString *type = [[notification userInfo] valueForKey: @"type"]; |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
15 printf("QuasimodeEvent type=%s\n", [type UTF8String]); |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
16 } |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
17 @end |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
18 |
19
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
19 int main(int argc, const char *argv[] ) |
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
20 { |
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
21 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
22 |
20
58522f82a39e
Brought back the notification center code to QuasimodalEventTap, we can just use the in-process one instead of setting up some complicated observer protocol.
Atul Varma <avarma@mozilla.com>
parents:
19
diff
changeset
|
23 QuasimodalEventTap *eventTap = [[QuasimodalEventTap alloc] |
22
ddc7cc16c48c
added 'quasimodeKey:' parameter to QuasimodalEventTap's init selector.
Atul Varma <avarma@mozilla.com>
parents:
21
diff
changeset
|
24 initWithName: @"test" |
ddc7cc16c48c
added 'quasimodeKey:' parameter to QuasimodalEventTap's init selector.
Atul Varma <avarma@mozilla.com>
parents:
21
diff
changeset
|
25 quasimodeKey: kCGEventFlagMaskAlternate]; |
19
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
26 |
21
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
27 TestObserver *observer = [[TestObserver alloc] init]; |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
28 |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
29 [[NSNotificationCenter defaultCenter] |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
30 addObserver: observer |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
31 selector: @selector(onEvent:) |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
32 name: @"QuasimodeEvent" |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
33 object: @"test"]; |
cdc615772d43
change notification protocol and made test program get notifications instead of relying on debug messages.
Atul Varma <avarma@mozilla.com>
parents:
20
diff
changeset
|
34 |
19
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
35 CFRunLoopRun(); |
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
36 |
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
37 [pool release]; |
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
38 |
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
39 return 0; |
8053681846ad
Refactored event tap C code into an Objective-C class.
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
40 } |