MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / onKeyDown

Method onKeyDown

Engine/source/gui/controls/guiTextEditCtrl.cpp:569–1150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569bool 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;

Callers

nothing calls this directly

Calls 10

switchFunction · 0.85
evaluateFunction · 0.85
getMaxFunction · 0.85
cutMethod · 0.80
setTextFunction · 0.70
isActiveFunction · 0.50
isAwakeFunction · 0.50
lengthMethod · 0.45
setMethod · 0.45
isNotEmptyMethod · 0.45

Tested by

no test coverage detected