comparison src/video/cocoa/SDL_cocoakeyboard.m @ 3683:4c5ab6841fdc

From: Jjgod Jiang Date: Mon, 18 Jan 2010 17:46:35 +0800 Subject: [PATCH] Polish text input handling for Mac OS X - Prevent crash caused by uninitialized video data - Prevent beeping caused by unhandled Cocoa selectors (like moveUp: moveDown:, etc.)
author Sam Lantinga <slouken@libsdl.org>
date Tue, 19 Jan 2010 07:28:51 +0000
parents 1ab77e93a6c9
children 5c64052fb476
comparison
equal deleted inserted replaced
3682:e4009cea0e82 3683:4c5ab6841fdc
97 SDL_SendKeyboardText(_keyboard, str); 97 SDL_SendKeyboardText(_keyboard, str);
98 } 98 }
99 99
100 - (void) doCommandBySelector:(SEL) myselector 100 - (void) doCommandBySelector:(SEL) myselector
101 { 101 {
102 [super doCommandBySelector: myselector]; 102 // No need to do anything since we are not using Cocoa
103 // selectors to handle special keys, instead we use SDL
104 // key events to do the same job.
103 } 105 }
104 106
105 - (BOOL) hasMarkedText 107 - (BOOL) hasMarkedText
106 { 108 {
107 return _markedText != nil; 109 return _markedText != nil;
647 void 649 void
648 Cocoa_StopTextInput(_THIS) 650 Cocoa_StopTextInput(_THIS)
649 { 651 {
650 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 652 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
651 653
652 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 654 if (data && data->fieldEdit) {
653 [data->fieldEdit removeFromSuperview]; 655 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
654 [data->fieldEdit release]; 656 [data->fieldEdit removeFromSuperview];
655 data->fieldEdit = nil; 657 [data->fieldEdit release];
656 [pool release]; 658 data->fieldEdit = nil;
659 [pool release];
660 }
657 } 661 }
658 662
659 void 663 void
660 Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect) 664 Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
661 { 665 {