Mercurial > projects > dwt-mac
comparison dwt/widgets/Text.d @ 152:834420cb1486
Delete, arrow keys and backspace are now working in text fields
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Thu, 11 Jun 2009 01:20:52 +0200 |
parents | 86fc761a24ae |
children | 8433dabeb15e |
comparison
equal
deleted
inserted
replaced
151:0ba75290f8ce | 152:834420cb1486 |
---|---|
1377 default: | 1377 default: |
1378 if (character !is '\t' && character < 0x20) return true; | 1378 if (character !is '\t' && character < 0x20) return true; |
1379 oldText = new_String ([character]); | 1379 oldText = new_String ([character]); |
1380 } | 1380 } |
1381 wchar[] newText = verifyText (oldText, start, end, nsEvent); | 1381 wchar[] newText = verifyText (oldText, start, end, nsEvent); |
1382 if (newText is null) return false; | 1382 //if (newText is null) return false; // DWT extension, empty strings could be null |
1383 if (charCount - (end - start) + newText.length () > textLimit) { | 1383 if (charCount - (end - start) + newText.length () > textLimit) { |
1384 return false; | 1384 return false; |
1385 } | 1385 } |
1386 result = newText is oldText; | 1386 result = newText == oldText; // DWT extension, Use "==" instead of "is" because newText can be null |
1387 if (newText !is oldText || hiddenText !is null) { | 1387 if (newText != oldText || hiddenText !is null) { |
1388 if ((style & DWT.SINGLE) !is 0) { | 1388 if ((style & DWT.SINGLE) !is 0) { |
1389 insertEditText (newText); | 1389 insertEditText (newText); |
1390 } else { | 1390 } else { |
1391 NSString str = NSString.stringWith16 (newText); | 1391 NSString str = NSString.stringWith16 (newText); |
1392 NSTextView widget = cast(NSTextView) view; | 1392 NSTextView widget = cast(NSTextView) view; |
1497 } | 1497 } |
1498 } | 1498 } |
1499 | 1499 |
1500 void setEditText (wchar[] string) { | 1500 void setEditText (wchar[] string) { |
1501 wchar [] buffer; | 1501 wchar [] buffer; |
1502 if ((style & DWT.PASSWORD) && echoCharacter !is '\0') { | 1502 if (((style & DWT.PASSWORD) is 0) && echoCharacter !is '\0') { |
1503 hiddenText = string; | 1503 hiddenText = string; |
1504 buffer = new wchar [Math.min(hiddenText.length (), textLimit)]; | 1504 buffer = new wchar [Math.min(hiddenText.length (), textLimit)]; |
1505 for (int i = 0; i < buffer.length; i++) buffer [i] = echoCharacter; | 1505 for (int i = 0; i < buffer.length; i++) buffer [i] = echoCharacter; |
1506 } else { | 1506 } else { |
1507 hiddenText = null; | 1507 hiddenText = null; |