| 580 | } |
| 581 | |
| 582 | bool GuiTextEditCtrl::onKeyDown(const GuiEvent &event) |
| 583 | { |
| 584 | if ( !isActive() || !isAwake() ) |
| 585 | return false; |
| 586 | |
| 587 | S32 stringLen = mTextBuffer.length(); |
| 588 | setUpdate(); |
| 589 | |
| 590 | // Ugly, but now I'm cool like MarkF. |
| 591 | if(event.keyCode == KEY_BACKSPACE) |
| 592 | goto dealWithBackspace; |
| 593 | |
| 594 | if ( event.modifier & SI_SHIFT ) |
| 595 | { |
| 596 | |
| 597 | // Added support for word jump selection. |
| 598 | |
| 599 | if ( event.modifier & SI_CTRL ) |
| 600 | { |
| 601 | switch ( event.keyCode ) |
| 602 | { |
| 603 | case KEY_LEFT: |
| 604 | { |
| 605 | S32 newpos = findPrevWord(); |
| 606 | |
| 607 | if ( mBlockStart == mBlockEnd ) |
| 608 | { |
| 609 | // There was not already a selection so start a new one. |
| 610 | mBlockStart = newpos; |
| 611 | mBlockEnd = mCursorPos; |
| 612 | } |
| 613 | else |
| 614 | { |
| 615 | // There was a selection already... |
| 616 | // In this case the cursor MUST be at either the |
| 617 | // start or end of that selection. |
| 618 | |
| 619 | if ( mCursorPos == mBlockStart ) |
| 620 | { |
| 621 | // We are at the start block and traveling left so |
| 622 | // just extend the start block farther left. |
| 623 | mBlockStart = newpos; |
| 624 | } |
| 625 | else |
| 626 | { |
| 627 | // We are at the end block BUT traveling left |
| 628 | // back towards the start block... |
| 629 | |
| 630 | if ( newpos > mBlockStart ) |
| 631 | { |
| 632 | // We haven't overpassed the existing start block |
| 633 | // so just trim back the end block. |
| 634 | mBlockEnd = newpos; |
| 635 | } |
| 636 | else if ( newpos == mBlockStart ) |
| 637 | { |
| 638 | // We are back at the start, so no more selection. |
| 639 | mBlockEnd = mBlockStart = 0; |