comparison src/video/uikit/SDL_uikitview.m @ 4565:e2d46c5c7483

Fixed key repeat detection on X11, and simplified the code for everyone else.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 21 Jul 2010 21:47:12 -0700
parents 95352c671a6e
children c24ba2cc9583
comparison
equal deleted inserted replaced
4563:ffd169948438 4565:e2d46c5c7483
243 /* UITextFieldDelegate method. Invoked when user types something. */ 243 /* UITextFieldDelegate method. Invoked when user types something. */
244 - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { 244 - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
245 245
246 if ([string length] == 0) { 246 if ([string length] == 0) {
247 /* it wants to replace text with nothing, ie a delete */ 247 /* it wants to replace text with nothing, ie a delete */
248 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE, SDL_FALSE); 248 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
249 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE, SDL_FALSE); 249 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
250 } 250 }
251 else { 251 else {
252 /* go through all the characters in the string we've been sent 252 /* go through all the characters in the string we've been sent
253 and convert them to key presses */ 253 and convert them to key presses */
254 int i; 254 int i;
270 mod = 0; 270 mod = 0;
271 } 271 }
272 272
273 if (mod & KMOD_SHIFT) { 273 if (mod & KMOD_SHIFT) {
274 /* If character uses shift, press shift down */ 274 /* If character uses shift, press shift down */
275 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT, SDL_FALSE); 275 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
276 } 276 }
277 /* send a keydown and keyup even for the character */ 277 /* send a keydown and keyup even for the character */
278 SDL_SendKeyboardKey(SDL_PRESSED, code, SDL_FALSE); 278 SDL_SendKeyboardKey(SDL_PRESSED, code);
279 SDL_SendKeyboardKey(SDL_RELEASED, code, SDL_FALSE); 279 SDL_SendKeyboardKey(SDL_RELEASED, code);
280 if (mod & KMOD_SHIFT) { 280 if (mod & KMOD_SHIFT) {
281 /* If character uses shift, press shift back up */ 281 /* If character uses shift, press shift back up */
282 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT, SDL_FALSE); 282 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
283 } 283 }
284 } 284 }
285 } 285 }
286 return NO; /* don't allow the edit! (keep placeholder text there) */ 286 return NO; /* don't allow the edit! (keep placeholder text there) */
287 } 287 }