MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / onKeyboardEvent

Method onKeyboardEvent

Source/Falcor/Utils/UI/Gui.cpp:1397–1433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1395}
1396
1397bool Gui::onKeyboardEvent(const KeyboardEvent& event)
1398{
1399 ImGui::SetCurrentContext(mpWrapper->mpContext);
1400 ImGuiIO& io = ImGui::GetIO();
1401
1402 if (event.type == KeyboardEvent::Type::Input)
1403 {
1404 std::string u8str = utf32ToUtf8(event.codepoint);
1405 io.AddInputCharactersUTF8(u8str.c_str());
1406
1407 // Gui consumes keyboard input
1408 return true;
1409 }
1410 else
1411 {
1412 uint32_t key = (uint32_t)(event.key == Input::Key::KeypadEnter ? Input::Key::Enter : event.key);
1413
1414 switch (event.type)
1415 {
1416 case KeyboardEvent::Type::KeyRepeated:
1417 case KeyboardEvent::Type::KeyPressed:
1418 io.KeysDown[key] = true;
1419 break;
1420 case KeyboardEvent::Type::KeyReleased:
1421 io.KeysDown[key] = false;
1422 break;
1423 default:
1424 FALCOR_UNREACHABLE();
1425 }
1426
1427 io.KeyCtrl = event.hasModifier(Input::Modifier::Ctrl);
1428 io.KeyAlt = event.hasModifier(Input::Modifier::Alt);
1429 io.KeyShift = event.hasModifier(Input::Modifier::Shift);
1430 io.KeySuper = false;
1431 return io.WantCaptureKeyboard;
1432 }
1433}
1434
1435Gui::Group Gui::Widgets::group(const std::string& label, bool beginExpanded)
1436{

Callers 2

handleKeyboardEventMethod · 0.45
handleKeyboardEventMethod · 0.45

Calls 2

utf32ToUtf8Function · 0.85
hasModifierMethod · 0.80

Tested by 1

handleKeyboardEventMethod · 0.36