comparison src/video/cocoa/SDL_cocoawindow.m @ 4915:834ce48a19c2

Fix right mouse event handling in Cocoa NSView in Cocoa has a different event handling procedure for right mouse events (rightMouseDown: etc.)
author Jjgod Jiang <gzjjgod@gmail.com>
date Sun, 09 May 2010 12:58:58 +0800
parents 50d0bff24d81
children 514f811a4887
comparison
equal deleted inserted replaced
4914:cc7ac6aaac5d 4915:834ce48a19c2
374 { 374 {
375 return YES; 375 return YES;
376 } 376 }
377 @end 377 @end
378 378
379 @interface SDLView : NSView {
380 Cocoa_WindowListener *listener;
381 }
382 @end
383
384 @implementation SDLView
385
386 - (id) initWithFrame: (NSRect) rect
387 listener: (Cocoa_WindowListener *) theListener
388 {
389 if (self = [super initWithFrame:rect]) {
390 listener = theListener;
391 }
392
393 return self;
394 }
395
396 - (void)rightMouseDown:(NSEvent *)theEvent
397 {
398 [listener mouseDown:theEvent];
399 }
400
401 @end
402
379 static int 403 static int
380 SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created) 404 SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
381 { 405 {
382 NSAutoreleasePool *pool; 406 NSAutoreleasePool *pool;
383 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; 407 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
405 429
406 /* Fill in the SDL window with the window data */ 430 /* Fill in the SDL window with the window data */
407 { 431 {
408 SDL_Rect bounds; 432 SDL_Rect bounds;
409 NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; 433 NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
434 NSView *contentView = [[SDLView alloc] initWithFrame: rect
435 listener: data->listener];
436 [nswindow setContentView: contentView];
437 [contentView release];
438
410 ConvertNSRect(&rect); 439 ConvertNSRect(&rect);
411 Cocoa_GetDisplayBounds(_this, display, &bounds); 440 Cocoa_GetDisplayBounds(_this, display, &bounds);
412 window->x = (int)rect.origin.x - bounds.x; 441 window->x = (int)rect.origin.x - bounds.x;
413 window->y = (int)rect.origin.y - bounds.y; 442 window->y = (int)rect.origin.y - bounds.y;
414 window->w = (int)rect.size.width; 443 window->w = (int)rect.size.width;