MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / innerSendEvent

Method innerSendEvent

source/windowing/StarTextBoxWidget.cpp:300–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300bool TextBoxWidget::innerSendEvent(InputEvent const& event) {
301 if (auto keyDown = event.ptr<KeyDownEvent>()) {
302 m_repeatKeyThreshold = Time::monotonicMilliseconds() + 300LL;
303
304 if (keyDown->key == Key::Escape) {
305 if (m_onEscapeKey) {
306 m_onEscapeKey(this);
307 return true;
308 }
309 return false;
310 }
311 if (keyDown->key == Key::Return || keyDown->key == Key::KeypadEnter) {
312 if (m_onEnterKey) {
313 m_onEnterKey(this);
314 return true;
315 }
316 return false;
317 }
318 if (keyDown->key == Key::Tab) {
319 if ((KeyMod::LShift & keyDown->mods) == KeyMod::LShift || (KeyMod::RShift & keyDown->mods) == KeyMod::RShift) {
320 if (m_prevFocus) {
321 if (auto prevWidget = parent()->fetchChild(*m_prevFocus)) {
322 prevWidget->focus();
323 return true;
324 }
325 }
326 } else {
327 if (m_nextFocus) {
328 if (auto nextWidget = parent()->fetchChild(*m_nextFocus)) {
329 nextWidget->focus();
330 return true;
331 }
332 }
333 }
334 return false;
335 }
336 if ((keyDown->mods & (KeyMod::LCtrl | KeyMod::RCtrl)) != KeyMod::NoMod) {
337 if (keyDown->key == Key::C) {
338 context()->setClipboard(m_text);
339 return true;
340 }
341 if (keyDown->key == Key::X) {
342 context()->setClipboard(m_text);
343 if (modText(""))
344 m_cursorOffset = 0;
345 return true;
346 }
347 if (keyDown->key == Key::V) {
348 String clipboard = context()->getClipboard();
349 if (modText(m_text.substr(0, m_cursorOffset) + clipboard + m_text.substr(m_cursorOffset)))
350 m_cursorOffset += clipboard.size();
351 return true;
352 }
353 }
354
355 auto calculateSteps = [&](bool dir) {
356 int steps = 1;
357 if ((keyDown->mods & (KeyMod::LCtrl | KeyMod::RCtrl)) != KeyMod::NoMod || (keyDown->mods & (KeyMod::LAlt | KeyMod::RAlt)) != KeyMod::NoMod) {

Callers

nothing calls this directly

Calls 7

focusMethod · 0.80
fetchChildMethod · 0.60
setClipboardMethod · 0.45
getClipboardMethod · 0.45
substrMethod · 0.45
sizeMethod · 0.45
findNextBoundaryMethod · 0.45

Tested by

no test coverage detected