MCPcopy Create free account
hub / github.com/MyGUI/mygui / onKeyButtonPressed

Method onKeyButtonPressed

MyGUIEngine/src/MyGUI_EditBox.cpp:389–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387 }
388
389 void EditBox::onKeyButtonPressed(KeyCode _key, Char _char)
390 {
391 if (mClientText == nullptr || getClientWidget() == nullptr)
392 {
393 Base::onKeyButtonPressed(_key, _char);
394 return;
395 }
396
397 // в статическом режиме ничего не доступно
398 if (mModeStatic)
399 {
400 Base::onKeyButtonPressed(_key, _char);
401 return;
402 }
403
404 InputManager& input = InputManager::getInstance();
405
406 mClientText->setVisibleCursor(true);
407 mCursorTimer = 0.0f;
408
409 auto editCmd = ToEditCommand(_key, input);
410
411 if (editCmd == EditCommand::LoseFocus)
412 {
413 InputManager::getInstance().setKeyFocusWidget(nullptr);
414 }
415 else if (editCmd == EditCommand::ErasePrevious)
416 {
417 // если нуно то удаляем выделенный текст
418 if (!mModeReadOnly)
419 {
420 // сбрасываем повтор
421 commandResetRedo();
422
423 if (!deleteTextSelect(true))
424 {
425 // прыгаем на одну назад и удаляем
426 if (mCursorPosition != 0)
427 {
428 mCursorPosition--;
429 eraseText(mCursorPosition, 1, true);
430 }
431 }
432 // отсылаем событие о изменении
433 eventEditTextChange(this);
434 }
435 }
436 else if (editCmd == EditCommand::EraseNext)
437 {
438 if (!mModeReadOnly)
439 {
440 // сбрасываем повтор
441 commandResetRedo();
442
443 // если нуно то удаляем выделенный текст
444 if (!deleteTextSelect(true))
445 {
446 if (mCursorPosition != mTextLength)

Callers

nothing calls this directly

Calls 12

ToEditCommandFunction · 0.85
setTextSelectionFunction · 0.85
isWhitespaceFunction · 0.85
setVisibleCursorMethod · 0.80
setKeyFocusWidgetMethod · 0.80
setCursorPositionMethod · 0.80
isShiftPressedMethod · 0.80
getCursorPointMethod · 0.80
sizeMethod · 0.45
getFontHeightMethod · 0.45
getCursorPositionMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected