comparison src/video/uikit/SDL_uikitview.m @ 4560:95352c671a6e

Added support for keyboard repeat (only tested on Windows so far)
author Sam Lantinga <slouken@libsdl.org>
date Tue, 20 Jul 2010 23:25:24 -0700
parents 06c7423f8c60
children e2d46c5c7483
comparison
equal deleted inserted replaced
4559:f8c3870af5a2 4560:95352c671a6e
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); 248 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE, SDL_FALSE);
249 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE); 249 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE, SDL_FALSE);
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); 275 SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT, SDL_FALSE);
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); 278 SDL_SendKeyboardKey(SDL_PRESSED, code, SDL_FALSE);
279 SDL_SendKeyboardKey(SDL_RELEASED, code); 279 SDL_SendKeyboardKey(SDL_RELEASED, code, SDL_FALSE);
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); 282 SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT, SDL_FALSE);
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 }