summary refs log tree commit diff stats
path: root/libs/cocos2d/Platforms/Mac/CCEventDispatcher.h
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-07-30 11:19:14 -0400
committerStarla Insigna <starla4444@gmail.com>2011-07-30 11:19:14 -0400
commit9cd57b731ab1c666d4a1cb725538fdc137763d12 (patch)
tree5bac45ae5157a1cb10c6e45500cbf72789917980 /libs/cocos2d/Platforms/Mac/CCEventDispatcher.h
downloadcartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.gz
cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.bz2
cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.zip
Initial commit (version 0.2.1)
Diffstat (limited to 'libs/cocos2d/Platforms/Mac/CCEventDispatcher.h')
-rwxr-xr-xlibs/cocos2d/Platforms/Mac/CCEventDispatcher.h277
1 files changed, 277 insertions, 0 deletions
diff --git a/libs/cocos2d/Platforms/Mac/CCEventDispatcher.h b/libs/cocos2d/Platforms/Mac/CCEventDispatcher.h new file mode 100755 index 0000000..06889e8 --- /dev/null +++ b/libs/cocos2d/Platforms/Mac/CCEventDispatcher.h
@@ -0,0 +1,277 @@
1/*
2 * cocos2d for iPhone: http://www.cocos2d-iphone.org
3 *
4 * Copyright (c) 2010 Ricardo Quesada
5 * Copyright (c) 2011 Zynga Inc.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 */
25
26// Only compile this code on Mac. These files should not be included on your iOS project.
27// But in case they are included, it won't be compiled.
28#import <Availability.h>
29#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
30#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
31
32#import <Cocoa/Cocoa.h>
33
34#import "MacGLView.h"
35#import "../../Support/uthash.h" // hack: uthash needs to be imported before utlist to prevent warning
36#import "../../Support/utlist.h"
37#import "../../ccConfig.h"
38
39#pragma mark -
40#pragma mark CCMouseEventDelegate
41
42/** CCMouseEventDelegate protocol.
43 Implement it in your node to receive any of mouse events
44 */
45@protocol CCMouseEventDelegate <NSObject>
46@optional
47
48//
49// left
50//
51/** called when the "mouseDown" event is received.
52 Return YES to avoid propagating the event to other delegates.
53 */
54-(BOOL) ccMouseDown:(NSEvent*)event;
55
56/** called when the "mouseDragged" event is received.
57 Return YES to avoid propagating the event to other delegates.
58 */
59-(BOOL) ccMouseDragged:(NSEvent*)event;
60
61/** called when the "mouseMoved" event is received.
62 Return YES to avoid propagating the event to other delegates.
63 By default, "mouseMoved" is disabled. To enable it, send the "setAcceptsMouseMovedEvents:YES" message to the main window.
64 */
65-(BOOL) ccMouseMoved:(NSEvent*)event;
66
67/** called when the "mouseUp" event is received.
68 Return YES to avoid propagating the event to other delegates.
69 */
70-(BOOL) ccMouseUp:(NSEvent*)event;
71
72
73//
74// right
75//
76
77/** called when the "rightMouseDown" event is received.
78 Return YES to avoid propagating the event to other delegates.
79 */
80-(BOOL) ccRightMouseDown:(NSEvent*)event;
81
82/** called when the "rightMouseDragged" event is received.
83 Return YES to avoid propagating the event to other delegates.
84 */
85-(BOOL) ccRightMouseDragged:(NSEvent*)event;
86
87/** called when the "rightMouseUp" event is received.
88 Return YES to avoid propagating the event to other delegates.
89 */
90-(BOOL) ccRightMouseUp:(NSEvent*)event;
91
92//
93// other
94//
95
96/** called when the "otherMouseDown" event is received.
97 Return YES to avoid propagating the event to other delegates.
98 */
99-(BOOL) ccOtherMouseDown:(NSEvent*)event;
100
101/** called when the "otherMouseDragged" event is received.
102 Return YES to avoid propagating the event to other delegates.
103 */
104-(BOOL) ccOtherMouseDragged:(NSEvent*)event;
105
106/** called when the "otherMouseUp" event is received.
107 Return YES to avoid propagating the event to other delegates.
108 */
109-(BOOL) ccOtherMouseUp:(NSEvent*)event;
110
111//
112// scroll wheel
113//
114
115/** called when the "scrollWheel" event is received.
116 Return YES to avoid propagating the event to other delegates.
117 */
118- (BOOL)ccScrollWheel:(NSEvent *)theEvent;
119
120
121//
122// enter / exit
123//
124
125/** called when the "mouseEntered" event is received.
126 Return YES to avoid propagating the event to other delegates.
127 */
128- (void)ccMouseEntered:(NSEvent *)theEvent;
129
130/** called when the "mouseExited" event is received.
131 Return YES to avoid propagating the event to other delegates.
132 */
133- (void)ccMouseExited:(NSEvent *)theEvent;
134
135@end
136
137#pragma mark -
138#pragma mark CCKeyboardEventDelegate
139
140/** CCKeyboardEventDelegate protocol.
141 Implement it in your node to receive any of keyboard events
142 */
143@protocol CCKeyboardEventDelegate <NSObject>
144@optional
145/** called when the "keyUp" event is received.
146 Return YES to avoid propagating the event to other delegates.
147 */
148-(BOOL) ccKeyUp:(NSEvent*)event;
149
150/** called when the "keyDown" event is received.
151 Return YES to avoid propagating the event to other delegates.
152 */
153-(BOOL) ccKeyDown:(NSEvent*)event;
154/** called when the "flagsChanged" event is received.
155 Return YES to avoid propagating the event to other delegates.
156 */
157-(BOOL) ccFlagsChanged:(NSEvent*)event;
158@end
159
160#pragma mark -
161#pragma mark CCTouchEventDelegate
162
163/** CCTouchEventDelegate protocol.
164 Implement it in your node to receive any of touch events
165 */
166@protocol CCTouchEventDelegate <NSObject>
167@optional
168/** called when the "touchesBegan" event is received.
169 Return YES to avoid propagating the event to other delegates.
170 */
171- (BOOL)ccTouchesBeganWithEvent:(NSEvent *)event;
172
173/** called when the "touchesMoved" event is received.
174 Return YES to avoid propagating the event to other delegates.
175 */
176- (BOOL)ccTouchesMovedWithEvent:(NSEvent *)event;
177
178/** called when the "touchesEnded" event is received.
179 Return YES to avoid propagating the event to other delegates.
180 */
181- (BOOL)ccTouchesEndedWithEvent:(NSEvent *)event;
182
183/** called when the "touchesCancelled" event is received.
184 Return YES to avoid propagating the event to other delegates.
185 */
186- (BOOL)ccTouchesCancelledWithEvent:(NSEvent *)event;
187
188@end
189
190
191#pragma mark -
192#pragma mark CCEventDispatcher
193
194struct _listEntry;
195
196/** CCEventDispatcher
197
198 This is object is responsible for dispatching the events:
199 - Mouse events
200 - Keyboard events
201 - Touch events
202
203 Only available on Mac
204 */
205@interface CCEventDispatcher : NSObject <MacEventDelegate> {
206
207 BOOL dispatchEvents_;
208
209 struct _listEntry *keyboardDelegates_;
210 struct _listEntry *mouseDelegates_;
211 struct _listEntry *touchDelegates_;
212}
213
214@property (nonatomic, readwrite) BOOL dispatchEvents;
215
216
217/** CCEventDispatcher singleton */
218+(CCEventDispatcher*) sharedDispatcher;
219
220#pragma mark CCEventDispatcher - Mouse
221
222/** Adds a mouse delegate to the dispatcher's list.
223 Delegates with a lower priority value will be called before higher priority values.
224 All the events will be propgated to all the delegates, unless the one delegate returns YES.
225
226 IMPORTANT: The delegate will be retained.
227 */
228-(void) addMouseDelegate:(id<CCMouseEventDelegate>) delegate priority:(NSInteger)priority;
229
230/** removes a mouse delegate */
231-(void) removeMouseDelegate:(id) delegate;
232
233/** Removes all mouse delegates, releasing all the delegates */
234-(void) removeAllMouseDelegates;
235
236#pragma mark CCEventDispatcher - Keyboard
237
238/** Adds a Keyboard delegate to the dispatcher's list.
239 Delegates with a lower priority value will be called before higher priority values.
240 All the events will be propgated to all the delegates, unless the one delegate returns YES.
241
242 IMPORTANT: The delegate will be retained.
243 */
244-(void) addKeyboardDelegate:(id<CCKeyboardEventDelegate>) delegate priority:(NSInteger)priority;
245
246/** removes a mouse delegate */
247-(void) removeKeyboardDelegate:(id) delegate;
248
249/** Removes all mouse delegates, releasing all the delegates */
250-(void) removeAllKeyboardDelegates;
251
252#pragma mark CCEventDispatcher - Touches
253
254/** Adds a Touch delegate to the dispatcher's list.
255 Delegates with a lower priority value will be called before higher priority values.
256 All the events will be propgated to all the delegates, unless the one delegate returns YES.
257
258 IMPORTANT: The delegate will be retained.
259 */
260- (void)addTouchDelegate:(id<CCTouchEventDelegate>)delegate priority:(NSInteger)priority;
261
262/** Removes a touch delegate */
263- (void)removeTouchDelegate:(id) delegate;
264
265/** Removes all touch delegates, releasing all the delegates */
266- (void)removeAllTouchDelegates;
267
268#pragma mark CCEventDispatcher - Dispatch Events
269
270#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
271-(void) dispatchQueuedEvents;
272#endif
273
274@end
275
276
277#endif // __MAC_OS_X_VERSION_MAX_ALLOWED