System Info
Dear ImGui 1.82 WIP (18101)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201703
define: __linux__
define: __GNUC__=8
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000440
DockingEnable
ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
HasMouseCursors
HasSetMousePos
PlatformHasViewports
HasMouseHoveredViewport
RendererHasVtxOffset
RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1280.00,720.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00
I'm using OpenGL 4.5 on Centos 7
My Issue/Question:
When undocking a modal window, using input text with the flag ImGuiInputTextFlags_EnterReturnsTrue appears to set every input to "click = return" even on re-creating the modal popup window (so this appears to effect every window). This behavior does not present itself if one instead uses a button to initiate a window close. This behaviors does not present itself when the window is docked in the main window.
Screenshots/Video
Vg8M9KL.-.Imgur.mp4
shows even the other window has click = return after the initial enter
TestSave2-2021-02-24_16.04.39.mp4
Standalone, minimal, complete and verifiable example: (see #2261 )
This should be able to reproduce the issue, hypothetically only stuff within draw_ui is relevant, but only depends on ImGUI, glad, glfw3 and a c++17 compatible compiler:
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <imgui.h>
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include <imgui_internal.h>
#include <misc/cpp/imgui_stdlib.h>
#include <iostream>
#include <optional>
#include <filesystem>
class TestContext{
public:
void draw_ui(bool* p_open);
private:
std::filesystem::path m_file_path;
void MenuBar();
};
void sub_ui(){
static double range_min;
static double range_max;
static double k;
static int size;
ImGui::Text("DetectorInfo:"
"\n\t range_a: [min %f, max %f]"
"\n\t k: [%f]"
"\n\t size: [width %i x height %i]"
,
range_min,
range_max,
k,
size,
size
);
float min = range_min;
float max = range_max;
if(ImGui::DragFloatRange2("range",
&min,
&max,
1.0f, 0.0f, 0.0f,
"Min: %.1fpx", "Max: %.1fpx",
ImGuiSliderFlags_AlwaysClamp)){
range_min = min;
range_max = max;
}
if (ImGui::InputDouble("k", &k)) {
k = std::max(k, 0.0);
}
}
void TestContext::draw_ui(bool *p_open) {
ImGuiWindowFlags window_flags =
ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
if (true) {
ImGuiViewport *viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->Pos);
ImGui::SetNextWindowSize(viewport->Size);
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
window_flags |=
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoMove;
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus |
ImGuiWindowFlags_NoNavFocus;
}
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
auto ret_val = ImGui::Begin("Test Window", p_open, window_flags);
ImGui::PopStyleVar();
if(ret_val){
MenuBar();
sub_ui();
ImGui::PopStyleVar(2);
ImGui::End();
}
}
void TestContext::MenuBar() {
static bool open_popup = false;
if (ImGui::BeginMainMenuBar()) {
static bool dark_mode = true;
if (ImGui::BeginMenu("Menu")) {
if (ImGui::MenuItem("Open Popup")) {
open_popup = true;
}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
if (open_popup) {
ImGui::OpenPopup("TEST Selection");
}
if (ImGui::BeginPopupModal("TEST Selection")) {
if (ImGui::Button("Cancel")) {
ImGui::CloseCurrentPopup();
open_popup = false;
m_file_path = "test";
}
static std::string text;
ImGui::Text("file");
ImGui::SameLine();
ImGui::PushItemWidth(-175);
if (ImGui::InputText("##file_123", &text,
ImGuiInputTextFlags_EnterReturnsTrue)) {
ImGui::CloseCurrentPopup();
open_popup = false;
m_file_path = text;
}
ImGui::SameLine();
if (ImGui::Button("Other")) {
ImGui::CloseCurrentPopup();
open_popup = false;
m_file_path = "test";
}
ImGui::EndPopup();
}
}
const char *glsl_version = "#version 450";
void setup_gl() {
if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)) {
throw std::runtime_error("Failed to initialize GLAD");
}
glFrontFace(GL_CCW);
// glEnable(GL_CULL_FACE); // Cull back facing polygons
glCullFace(GL_BACK);
}
void application() {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+OpenGL3 example", NULL, NULL);
if (window == NULL) {
return;
}
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
setup_gl();
// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO &io = ImGui::GetIO();
(void) io;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
#ifdef IMGUI_DEBUG_LOG_DOCKING
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
#endif
// Setup Dear ImGui style
ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic();
// Setup Platform/Renderer backends
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init(glsl_version);
// Our state
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
bool open = true;
TestContext test_context;
while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
// Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
ImGui::ShowDemoWindow();
test_context.draw_ui(&open);
// Rendering
ImGui::Render();
int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
glClearColor(clear_color.x, clear_color.y, clear_color.z,
clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
GLFWwindow *backup_current_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(backup_current_context);
}
glfwSwapBuffers(window);
}
// Cleanup
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window);
}
int main() {
glfwSetErrorCallback([](int error_code, const char *description) {
std::cout << "GLFW Error " << error_code << ": "
<< description << "\n";
});
int inited = glfwInit();
if (!inited) {
std::cout << "Couldn't init glfw" << std::endl;
return 1;
}
application();
glfwTerminate();
return 0;
}
System Info
I'm using OpenGL 4.5 on Centos 7
My Issue/Question:
When undocking a modal window, using input text with the flag
ImGuiInputTextFlags_EnterReturnsTrueappears to set every input to "click = return" even on re-creating the modal popup window (so this appears to effect every window). This behavior does not present itself if one instead uses a button to initiate a window close. This behaviors does not present itself when the window is docked in the main window.Screenshots/Video
Vg8M9KL.-.Imgur.mp4
shows even the other window has click = return after the initial enter
TestSave2-2021-02-24_16.04.39.mp4
Standalone, minimal, complete and verifiable example: (see #2261)
This should be able to reproduce the issue, hypothetically only stuff within draw_ui is relevant, but only depends on ImGUI, glad, glfw3 and a c++17 compatible compiler: