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

Method onKeyDown

Engine/source/gui/controls/guiConsoleEditCtrl.cpp:73–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

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
utf8Method · 0.45

Tested by

no test coverage detected