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

Method onKeyDown

Engine/source/gui/controls/guiMLTextEditCtrl.cpp:139–298  ·  view source on GitHub ↗

-------------------------------------------------------------------------- Key events...

Source from the content-addressed store, hash-verified

137//--------------------------------------------------------------------------
138// Key events...
139bool GuiMLTextEditCtrl::onKeyDown(const GuiEvent& event)
140{
141 if ( !isActive() )
142 return false;
143
144 setUpdate();
145 //handle modifiers first...
146 if (event.modifier & SI_PRIMARY_CTRL)
147 {
148 switch(event.keyCode)
149 {
150 //copy/cut
151 case KEY_C:
152 case KEY_X:
153 {
154 //make sure we actually have something selected
155 if (mSelectionActive)
156 {
157 copyToClipboard(mSelectionStart, mSelectionEnd);
158
159 //if we're cutting, also delete the selection
160 if (event.keyCode == KEY_X)
161 {
162 mSelectionActive = false;
163 deleteChars(mSelectionStart, mSelectionEnd);
164 mCursorPosition = mSelectionStart;
165 }
166 else
167 mCursorPosition = mSelectionEnd + 1;
168 }
169 return true;
170 }
171
172 //paste
173 case KEY_V:
174 {
175 const char *clipBuf = Platform::getClipboard();
176 if (dStrlen(clipBuf) > 0)
177 {
178 // Normal ascii keypress. Go ahead and add the chars...
179 if (mSelectionActive == true)
180 {
181 mSelectionActive = false;
182 deleteChars(mSelectionStart, mSelectionEnd);
183 mCursorPosition = mSelectionStart;
184 }
185
186 insertChars(clipBuf, dStrlen(clipBuf), mCursorPosition);
187 }
188 return true;
189 }
190
191 default:
192 break;
193 }
194 }
195 else if ( event.modifier & SI_SHIFT )
196 {

Callers

nothing calls this directly

Calls 5

evaluateFunction · 0.85
getCopy8Method · 0.80
isActiveFunction · 0.50
dStrlenFunction · 0.50
isValidCharMethod · 0.45

Tested by

no test coverage detected