MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / DemoWindowInputs

Function DemoWindowInputs

external/imgui/imgui_demo.cpp:7917–8223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7915//-----------------------------------------------------------------------------
7916
7917static void DemoWindowInputs()
7918{
7919 if (ImGui::CollapsingHeader("Inputs & Focus"))
7920 {
7921 ImGuiIO& io = ImGui::GetIO();
7922
7923 // Display inputs submitted to ImGuiIO
7924 ImGui::SetNextItemOpen(true, ImGuiCond_Once);
7925 bool inputs_opened = ImGui::TreeNode("Inputs");
7926 ImGui::SameLine();
7927 HelpMarker(
7928 "This is a simplified view. See more detailed input state:\n"
7929 "- in 'Tools->Metrics/Debugger->Inputs'.\n"
7930 "- in 'Tools->Debug Log->IO'.");
7931 if (inputs_opened)
7932 {
7933 IMGUI_DEMO_MARKER("Inputs & Focus/Inputs");
7934 if (ImGui::IsMousePosValid())
7935 ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y);
7936 else
7937 ImGui::Text("Mouse pos: <INVALID>");
7938 ImGui::Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y);
7939 ImGui::Text("Mouse down:");
7940 for (int i = 0; i < IM_COUNTOF(io.MouseDown); i++) if (ImGui::IsMouseDown(i)) { ImGui::SameLine(); ImGui::Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); }
7941 ImGui::Text("Mouse wheel: %.1f", io.MouseWheel);
7942 ImGui::Text("Mouse clicked count:");
7943 for (int i = 0; i < IM_COUNTOF(io.MouseDown); i++) if (io.MouseClickedCount[i] > 0) { ImGui::SameLine(); ImGui::Text("b%d: %d", i, io.MouseClickedCount[i]); }
7944
7945 // We iterate both legacy native range and named ImGuiKey ranges. This is a little unusual/odd but this allows
7946 // displaying the data for old/new backends.
7947 // User code should never have to go through such hoops!
7948 // You can generally iterate between ImGuiKey_NamedKey_BEGIN and ImGuiKey_NamedKey_END.
7949 struct funcs { static bool IsLegacyNativeDupe(ImGuiKey) { return false; } };
7950 ImGuiKey start_key = ImGuiKey_NamedKey_BEGIN;
7951 ImGui::Text("Keys down:"); for (ImGuiKey key = start_key; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1)) { if (funcs::IsLegacyNativeDupe(key) || !ImGui::IsKeyDown(key)) continue; ImGui::SameLine(); ImGui::Text((key < ImGuiKey_NamedKey_BEGIN) ? "\"%s\"" : "\"%s\" %d", ImGui::GetKeyName(key), key); }
7952 ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
7953 ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
7954
7955 ImGui::TreePop();
7956 }
7957
7958 // Display ImGuiIO output flags
7959 ImGui::SetNextItemOpen(true, ImGuiCond_Once);
7960 bool outputs_opened = ImGui::TreeNode("Outputs");
7961 ImGui::SameLine();
7962 HelpMarker(
7963 "The value of io.WantCaptureMouse and io.WantCaptureKeyboard are normally set by Dear ImGui "
7964 "to instruct your application of how to route inputs. Typically, when a value is true, it means "
7965 "Dear ImGui wants the corresponding inputs and we expect the underlying application to ignore them.\n\n"
7966 "The most typical case is: when hovering a window, Dear ImGui set io.WantCaptureMouse to true, "
7967 "and underlying application should ignore mouse inputs (in practice there are many and more subtle "
7968 "rules leading to how those flags are set).");
7969 if (outputs_opened)
7970 {
7971 IMGUI_DEMO_MARKER("Inputs & Focus/Outputs");
7972 ImGui::Text("io.WantCaptureMouse: %d", io.WantCaptureMouse);
7973 ImGui::Text("io.WantCaptureMouseUnlessPopupClose: %d", io.WantCaptureMouseUnlessPopupClose);
7974 ImGui::Text("io.WantCaptureKeyboard: %d", io.WantCaptureKeyboard);

Callers 1

ShowDemoWindowMethod · 0.85

Calls 5

HelpMarkerFunction · 0.85
ImVec4Class · 0.85
ImVec2Function · 0.85
GetForegroundDrawListFunction · 0.85
AddLineMethod · 0.80

Tested by

no test coverage detected