ImGui ReadOnly flag causes freezing in all widgets #6758

Closed
opened 2023-08-28 16:25:17 +00:00 by luis605 · 3 comments
luis605 commented 2023-08-28 16:25:17 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

Version: 1.89.2
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: rlImGui
Operating System: Linux Mint 21.1 Vera

My Issue/Question:
When creating a ReadOnly SliderFloat and press it while it is at a read only state, every imgui widget being rendered in the main window/process gets unresponsive.

Screenshots/Video

https://github.com/ocornut/imgui/assets/60551627/a20ea7a1-f7b8-4af5-83e9-438752d67fd3

Standalone, minimal, complete and verifiable example:

#include "imgui/imgui.h"
#include "imgui/imgui_internal.h"
#include "include/rlImGui.h"
#include "include/raylib.h"
#include <iostream>
int main(int argc, char* argv[])
{
	int screenWidth = 1280;
	int screenHeight = 800;

	SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT);
	InitWindow(screenWidth, screenHeight, "raylib-Extras [ImGui] example - simple ImGui Demo");
	SetTargetFPS(144);
	rlImGuiSetup(true);
	
	while (!WindowShouldClose())    
	{
		BeginDrawing();
		ClearBackground(DARKGRAY);
		
		rlImGuiBegin();

        bool readOnly = true;
		float size_x = 10.0f;

        ImGui::SliderFloat("##ScaleX", &size_x, 0, 100, "%.3f", readOnly ? ImGuiSliderFlags_ReadOnly : 0);

        if (ImGui::Button("Hi There", ImVec2(100,100)))
        {
            std::cout << "pressed\n";
        }

        ImGui::Begin("Another Window");

        if (ImGui::Button("Hi There 2", ImVec2(100,100)))
        {
            std::cout << "pressed\n";
        }

        ImGui::End();
        
		
		rlImGuiEnd();

		EndDrawing();
		
	}
	
    rlImGuiShutdown();
    CloseWindow();

	return 0;
}


Version/Branch of Dear ImGui: Version: 1.89.2 Branch: docking Back-end/Renderer/Compiler/OS Back-ends: rlImGui Operating System: Linux Mint 21.1 Vera **My Issue/Question:** When creating a ReadOnly SliderFloat and press it while it is at a read only state, every imgui widget being rendered in the main window/process gets unresponsive. **Screenshots/Video** https://github.com/ocornut/imgui/assets/60551627/a20ea7a1-f7b8-4af5-83e9-438752d67fd3 **Standalone, minimal, complete and verifiable example:** ```cpp #include "imgui/imgui.h" #include "imgui/imgui_internal.h" #include "include/rlImGui.h" #include "include/raylib.h" #include <iostream> int main(int argc, char* argv[]) { int screenWidth = 1280; int screenHeight = 800; SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT); InitWindow(screenWidth, screenHeight, "raylib-Extras [ImGui] example - simple ImGui Demo"); SetTargetFPS(144); rlImGuiSetup(true); while (!WindowShouldClose()) { BeginDrawing(); ClearBackground(DARKGRAY); rlImGuiBegin(); bool readOnly = true; float size_x = 10.0f; ImGui::SliderFloat("##ScaleX", &size_x, 0, 100, "%.3f", readOnly ? ImGuiSliderFlags_ReadOnly : 0); if (ImGui::Button("Hi There", ImVec2(100,100))) { std::cout << "pressed\n"; } ImGui::Begin("Another Window"); if (ImGui::Button("Hi There 2", ImVec2(100,100))) { std::cout << "pressed\n"; } ImGui::End(); rlImGuiEnd(); EndDrawing(); } rlImGuiShutdown(); CloseWindow(); return 0; } ```
ocornut commented 2023-08-28 16:46:20 +00:00 (Migrated from github.com)

Thank you Luis for reporting.

AFAIK this has never worked on Sliders from the first commit this was introduced (fdc526e8f) - the commit wanted it to Drags.

ImGuiSliderFlags_ReadOnly is an undocumented flag from imgui_internal.h which was initially designed for a specific use of DragFloat(). For consistency I will fix this however I reckon you should be using BeginDisabled()/EndDisabled() instead?

ReadOnly is internal and meant to provide a specific behavior of allowing hovering/highlight but preventing edits.
Disabled mode will prevent both together.

Thank you Luis for reporting. AFAIK this has never worked on Sliders from the first commit this was introduced (fdc526e8f) - the commit wanted it to Drags. `ImGuiSliderFlags_ReadOnly` is an undocumented flag from imgui_internal.h which was initially designed for a specific use of `DragFloat()`. For consistency I will fix this _however_ I reckon you should be using `BeginDisabled()`/`EndDisabled()` instead? ReadOnly is internal and meant to provide a specific behavior of allowing hovering/highlight but preventing edits. Disabled mode will prevent both together.
luis605 commented 2023-08-28 16:51:07 +00:00 (Migrated from github.com)

Thank you, I will use Begin Disabled instead.

Thank you, I will use Begin Disabled instead.
ocornut commented 2023-08-29 10:20:09 +00:00 (Migrated from github.com)

I have also pushed the fix now with f93d0be, but I may remove ImGuiSliderFlags_ReadOnly in the future and instead promote using generic item flags ImGuiItemFlags_ReadOnly but it's not widely supported yet.

I have also pushed the fix now with f93d0be, but I may remove `ImGuiSliderFlags_ReadOnly` in the future and instead promote using generic item flags `ImGuiItemFlags_ReadOnly` but it's not widely supported yet.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#6758
No description provided.