MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / KeyPressed

Method KeyPressed

ogsr_engine/xrGame/ui/UICustomEdit.cpp:119–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119bool CUICustomEdit::KeyPressed(int dik)
120{
121 bool bChanged = false;
122
123 switch (dik)
124 {
125 case DIK_TAB: {
126 // Табы нельзя добавлять здесь, такого символа в шрифтах нет, он не отображается в игре.
127 // А проблемы доставить может при получении введенного текста через GetText() в скрипте,
128 // когда полученный текст будет отличаться от отображаемого из-за наличия в нём табов.
129 return true;
130 }
131 case DIK_LEFT:
132 case DIKEYBOARD_LEFT: m_lines.DecCursorPos(); break;
133 case DIK_RIGHT:
134 case DIKEYBOARD_RIGHT: m_lines.IncCursorPos(); break;
135 case DIK_ESCAPE:
136 if (strlen(GetText()))
137 {
138 SetText("");
139 bChanged = true;
140 }
141 else
142 {
143 GetParent()->SetKeyboardCapture(this, false);
144 m_bInputFocus = false;
145 m_iKeyPressAndHold = 0;
146 }
147 break;
148 case DIK_RETURN:
149 case DIK_NUMPADENTER:
150 GetParent()->SetKeyboardCapture(this, false);
151 m_bInputFocus = false;
152 m_iKeyPressAndHold = 0;
153 GetMessageTarget()->SendMessage(this, EDIT_TEXT_COMMIT, NULL);
154 break;
155 case DIK_BACKSPACE:
156 m_lines.DelLeftChar();
157 bChanged = true;
158 break;
159 case DIK_DELETE:
160 case DIKEYBOARD_DELETE:
161 m_lines.DelCurrentChar();
162 bChanged = true;
163 break;
164 default:
165 const u16 out_me = pInput->DikToChar(dik, m_lines.GetFont()->IsMultibyte());
166 if (out_me)
167 {
168 if (!m_bNumbersOnly || (out_me >= '0' && out_me <= '9') || (m_bFloatNumbers && out_me == '.' && !strchr(m_lines.GetText(), '.')))
169 {
170 AddChar(out_me);
171 bChanged = true;
172 }
173 }
174 }
175
176 if (bChanged)

Callers

nothing calls this directly

Calls 11

GetTextFunction · 0.85
GetParentFunction · 0.85
DecCursorPosMethod · 0.80
IncCursorPosMethod · 0.80
SetKeyboardCaptureMethod · 0.80
DelLeftCharMethod · 0.80
DelCurrentCharMethod · 0.80
DikToCharMethod · 0.80
SendMessageMethod · 0.45
GetFontMethod · 0.45
GetTextMethod · 0.45

Tested by

no test coverage detected