comparison dwt/widgets/Combo.d @ 139:86fc761a24ae

Fixes #11
author Jacob Carlborg <doob@me.com>
date Thu, 04 Jun 2009 23:23:10 +0200
parents 63a09873578e
children d8c1f0540bcb
comparison
equal deleted inserted replaced
138:3d9eb62cd2e3 139:86fc761a24ae
1233 int charCount = getCharCount (); 1233 int charCount = getCharCount ();
1234 Point selection = getSelection (); 1234 Point selection = getSelection ();
1235 int start = selection.x, end = selection.y; 1235 int start = selection.x, end = selection.y;
1236 ushort keyCode = nsEvent.keyCode (); 1236 ushort keyCode = nsEvent.keyCode ();
1237 NSString characters = nsEvent.charactersIgnoringModifiers(); 1237 NSString characters = nsEvent.charactersIgnoringModifiers();
1238 wchar character = characters.characterAtIndex(0); 1238 char character = toChar(characters.characterAtIndex(0));
1239 switch (keyCode) { 1239 switch (keyCode) {
1240 case 51: /* Backspace */ 1240 case 51: /* Backspace */
1241 if (start is end) { 1241 if (start is end) {
1242 if (start is 0) return true; 1242 if (start is 0) return true;
1243 start = Math.max (0, start - 1); 1243 start = Math.max (0, start - 1);
1251 break; 1251 break;
1252 default: 1252 default:
1253 if (character !is '\t' && character < 0x20) return true; 1253 if (character !is '\t' && character < 0x20) return true;
1254 oldText = new_String ([character]); 1254 oldText = new_String ([character]);
1255 } 1255 }
1256 String newText = verifyText (oldText, start, end, nsEvent); 1256 char[] newText = verifyText (oldText, start, end, nsEvent);
1257 if (newText is null) return false; 1257 if (newText is null) return false;
1258 if (charCount - (end - start) + newText.length () > textLimit) { 1258 if (charCount - (end - start) + newText.length () > textLimit) {
1259 return false; 1259 return false;
1260 } 1260 }
1261 result = newText is oldText; 1261 result = newText is oldText;