| 1395 | } |
| 1396 | |
| 1397 | bool 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 | |
| 1435 | Gui::Group Gui::Widgets::group(const std::string& label, bool beginExpanded) |
| 1436 | { |