Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

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.)
  • Loading branch information
slouken committed Jan 19, 2010
1 parent eba8e33 commit 45b04c9b247313c2b48771c91ebeebe2dfb2fc54
Showing with 13 additions and 10 deletions.
  1. +3 −3 src/video/SDL_video.c
  2. +0 −1 src/video/cocoa/SDL_cocoaevents.m
  3. +10 −6 src/video/cocoa/SDL_cocoakeyboard.m
@@ -3580,7 +3580,7 @@ SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo *info)
void
SDL_StartTextInput(void)
{
if (_this->StartTextInput) {
if (_this && _this->StartTextInput) {
_this->StartTextInput(_this);
}
SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
@@ -3590,7 +3590,7 @@ SDL_StartTextInput(void)
void
SDL_StopTextInput(void)
{
if (_this->StopTextInput) {
if (_this && _this->StopTextInput) {
_this->StopTextInput(_this);
}
SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
@@ -3600,7 +3600,7 @@ SDL_StopTextInput(void)
void
SDL_SetTextInputRect(SDL_Rect *rect)
{
if (_this->SetTextInputRect) {
if (_this && _this->SetTextInputRect) {
_this->SetTextInputRect(_this, rect);
}
}
@@ -212,7 +212,6 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende
case NSFlagsChanged:
Cocoa_HandleKeyEvent(_this, event);
/* Fall through to pass event to NSApp; er, nevermind... */
/* FIXME: Find a way to stop the beeping, using delegate */

/* Add to support system-wide keyboard shortcuts like CMD+Space */
if (([event modifierFlags] & NSCommandKeyMask) || [event type] == NSFlagsChanged)
@@ -99,7 +99,9 @@ - (void) insertText:(id) aString

- (void) doCommandBySelector:(SEL) myselector
{
[super doCommandBySelector: myselector];
// No need to do anything since we are not using Cocoa
// selectors to handle special keys, instead we use SDL
// key events to do the same job.
}

- (BOOL) hasMarkedText
@@ -649,11 +651,13 @@ - (NSArray *) validAttributesForMarkedText
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[data->fieldEdit removeFromSuperview];
[data->fieldEdit release];
data->fieldEdit = nil;
[pool release];
if (data && data->fieldEdit) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[data->fieldEdit removeFromSuperview];
[data->fieldEdit release];
data->fieldEdit = nil;
[pool release];
}
}

void

0 comments on commit 45b04c9

Please sign in to comment.