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