| 2922 | } |
| 2923 | |
| 2924 | static void ShowDemoWindowMisc() |
| 2925 | { |
| 2926 | if (ImGui::CollapsingHeader("Filtering")) |
| 2927 | { |
| 2928 | // Helper class to easy setup a text filter. |
| 2929 | // You may want to implement a more feature-full filtering scheme in your own application. |
| 2930 | static ImGuiTextFilter filter; |
| 2931 | ImGui::Text("Filter usage:\n" |
| 2932 | " \"\" display all lines\n" |
| 2933 | " \"xxx\" display lines containing \"xxx\"\n" |
| 2934 | " \"xxx,yyy\" display lines containing \"xxx\" or \"yyy\"\n" |
| 2935 | " \"-xxx\" hide lines containing \"xxx\""); |
| 2936 | filter.Draw(); |
| 2937 | const char* lines[] = { "aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world" }; |
| 2938 | for (int i = 0; i < IM_ARRAYSIZE(lines); i++) |
| 2939 | if (filter.PassFilter(lines[i])) |
| 2940 | ImGui::BulletText("%s", lines[i]); |
| 2941 | } |
| 2942 | |
| 2943 | if (ImGui::CollapsingHeader("Inputs, Navigation & Focus")) |
| 2944 | { |
| 2945 | ImGuiIO& io = ImGui::GetIO(); |
| 2946 | |
| 2947 | // Display ImGuiIO output flags |
| 2948 | ImGui::Text("WantCaptureMouse: %d", io.WantCaptureMouse); |
| 2949 | ImGui::Text("WantCaptureKeyboard: %d", io.WantCaptureKeyboard); |
| 2950 | ImGui::Text("WantTextInput: %d", io.WantTextInput); |
| 2951 | ImGui::Text("WantSetMousePos: %d", io.WantSetMousePos); |
| 2952 | ImGui::Text("NavActive: %d, NavVisible: %d", io.NavActive, io.NavVisible); |
| 2953 | |
| 2954 | // Display Keyboard/Mouse state |
| 2955 | if (ImGui::TreeNode("Keyboard, Mouse & Navigation State")) |
| 2956 | { |
| 2957 | if (ImGui::IsMousePosValid()) |
| 2958 | ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y); |
| 2959 | else |
| 2960 | ImGui::Text("Mouse pos: <INVALID>"); |
| 2961 | ImGui::Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y); |
| 2962 | ImGui::Text("Mouse down:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (io.MouseDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); } |
| 2963 | ImGui::Text("Mouse clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } |
| 2964 | ImGui::Text("Mouse dbl-clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDoubleClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } |
| 2965 | ImGui::Text("Mouse released:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } |
| 2966 | ImGui::Text("Mouse wheel: %.1f", io.MouseWheel); |
| 2967 | |
| 2968 | ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (io.KeysDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("%d (0x%X) (%.02f secs)", i, i, io.KeysDownDuration[i]); } |
| 2969 | ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); } |
| 2970 | ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); } |
| 2971 | ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : ""); |
| 2972 | 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. |
| 2973 | |
| 2974 | ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f", i, io.NavInputs[i]); } |
| 2975 | ImGui::Text("NavInputs pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] == 0.0f) { ImGui::SameLine(); ImGui::Text("[%d]", i); } |
| 2976 | ImGui::Text("NavInputs duration:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f", i, io.NavInputsDownDuration[i]); } |
| 2977 | |
| 2978 | ImGui::Button("Hovering me sets the\nkeyboard capture flag"); |
| 2979 | if (ImGui::IsItemHovered()) |
| 2980 | ImGui::CaptureKeyboardFromApp(true); |
| 2981 | ImGui::SameLine(); |
no test coverage detected