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

Method onKeyDown

Engine/source/gui/controls/guiConsoleEditCtrl.cpp:72–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72bool GuiConsoleEditCtrl::onKeyDown(const GuiEvent &event)
73{
74 setUpdate();
75
76 if (event.keyCode == KEY_TAB)
77 {
78 // Get a buffer that can hold the completed text...
79 FrameTemp<UTF8> tmpBuff(GuiTextCtrl::MAX_STRING_LENGTH);
80 // And copy the text to be completed into it.
81 mTextBuffer.getCopy8(tmpBuff, GuiTextCtrl::MAX_STRING_LENGTH);
82
83 // perform the completion
84 bool forward = (event.modifier & SI_SHIFT) == 0;
85 mCursorPos = Con::tabComplete(tmpBuff, mCursorPos, GuiTextCtrl::MAX_STRING_LENGTH, forward);
86
87 // place results in our buffer.
88 mTextBuffer.set(tmpBuff);
89 return true;
90 }
91 else if ((event.keyCode == KEY_PAGE_UP) || (event.keyCode == KEY_PAGE_DOWN))
92 {
93 // See if there's some other widget that can scroll the console history.
94 if (mUseSiblingScroller)
95 {
96 if (mSiblingScroller)
97 {
98 return mSiblingScroller->onKeyDown(event);
99 }
100 else
101 {
102 // Let's see if we can find it...
103 SimGroup* pGroup = getGroup();
104 if (pGroup)
105 {
106 // Find the first scroll control in the same group as us.
107 for (SimSetIterator itr(pGroup); *itr; ++itr)
108 {
109 mSiblingScroller = dynamic_cast<GuiScrollCtrl*>(*itr);
110 if (mSiblingScroller != NULL)
111 {
112 return mSiblingScroller->onKeyDown(event);
113 }
114 }
115 }
116
117 // No luck... so don't try, next time.
118 mUseSiblingScroller = false;
119 }
120 }
121 }
122 else if( event.keyCode == KEY_RETURN || event.keyCode == KEY_NUMPADENTER )
123 {
124 if ( event.modifier & SI_SHIFT &&
125 mTextBuffer.length() + dStrlen("echo();") <= GuiTextCtrl::MAX_STRING_LENGTH )
126 {
127 // Wrap the text with echo( %s );
128
129 char buf[GuiTextCtrl::MAX_STRING_LENGTH];

Callers

nothing calls this directly

Calls 9

tabCompleteFunction · 0.85
getTextFunction · 0.85
getCopy8Method · 0.80
replaceMethod · 0.80
setTextFunction · 0.70
dStrlenFunction · 0.50
setMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected