| 1483 | } |
| 1484 | |
| 1485 | void GuiTextEditCtrl::handleCharInput( U16 ascii ) |
| 1486 | { |
| 1487 | S32 stringLen = mTextBuffer.length(); |
| 1488 | |
| 1489 | // Get the character ready to add to a UTF8 string. |
| 1490 | UTF16 convertedChar[2] = { ascii, 0 }; |
| 1491 | |
| 1492 | //see if it's a number field |
| 1493 | if ( mProfile->mNumbersOnly ) |
| 1494 | { |
| 1495 | if (ascii == '-') |
| 1496 | { |
| 1497 | //a minus sign only exists at the beginning, and only a single minus sign |
| 1498 | if (mCursorPos != 0 && !isAllTextSelected()) |
| 1499 | { |
| 1500 | invalidText(); |
| 1501 | return; |
| 1502 | } |
| 1503 | |
| 1504 | if (mInsertOn && (mTextBuffer.getChar(0) == '-')) |
| 1505 | { |
| 1506 | invalidText(); |
| 1507 | return; |
| 1508 | } |
| 1509 | } |
| 1510 | // BJTODO: This is probably not unicode safe. |
| 1511 | else if (ascii != '.' && (ascii < '0' || ascii > '9')) |
| 1512 | { |
| 1513 | invalidText(); |
| 1514 | return; |
| 1515 | } |
| 1516 | else |
| 1517 | validText(); |
| 1518 | } |
| 1519 | |
| 1520 | //save the current state |
| 1521 | saveUndoState(); |
| 1522 | |
| 1523 | bool alreadyCut = false; |
| 1524 | |
| 1525 | //delete anything highlighted |
| 1526 | if ( mBlockEnd > 0 ) |
| 1527 | { |
| 1528 | mTextBuffer.cut(mBlockStart, mBlockEnd-mBlockStart); |
| 1529 | mCursorPos = mBlockStart; |
| 1530 | mBlockStart = 0; |
| 1531 | mBlockEnd = 0; |
| 1532 | |
| 1533 | // We just changed the string length! |
| 1534 | // Get its new value. |
| 1535 | stringLen = mTextBuffer.length(); |
| 1536 | |
| 1537 | // If we already had text highlighted, we just want to cut that text. |
| 1538 | // Don't cut the next character even if insert is not on. |
| 1539 | alreadyCut = true; |
| 1540 | } |
| 1541 | |
| 1542 | if ( ( mInsertOn && ( stringLen < mMaxStrLen ) ) || |