From 1c48525f1875c6521cce39da2dec556dc234d982 Mon Sep 17 00:00:00 2001 From: Jjgod Jiang Date: Thu, 12 Aug 2010 16:00:47 +0200 Subject: [PATCH] Fix for deleting the last uncommit character --- src/video/cocoa/SDL_cocoakeyboard.m | 2 ++ test/testime.c | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index e2aea94fa..13756cc3c 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -144,6 +144,8 @@ - (void) unmarkText { [_markedText release]; _markedText = nil; + + SDL_SendEditingText("", 0, 0); } - (NSRect) firstRectForCharacterRange: (NSRange) theRange diff --git a/test/testime.c b/test/testime.c index 6975d652d..c2b5b045f 100644 --- a/test/testime.c +++ b/test/testime.c @@ -136,11 +136,13 @@ static void RenderText(SDL_Surface *sur, int x, int y, SDL_Color color) { - SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, text, color); - SDL_Rect dest = { x, y, textSur->w, textSur->h }; + if (text && strlen(text)) { + SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, text, color); + SDL_Rect dest = { x, y, textSur->w, textSur->h }; - SDL_BlitSurface(textSur, NULL, sur, &dest); - SDL_FreeSurface(textSur); + SDL_BlitSurface(textSur, NULL, sur, &dest); + SDL_FreeSurface(textSur); + } } #endif