Widgets not working


#1

Hi everyone,

I decided to implement a menu UI using polymorphism but the widgets stopped working. By this I mean the hover over color change is not working or the collision with the button. It is the same case for sliders and checkbox.
This is the code of the MainMenu class which inherits from InmediateUI:

ImGui::Begin(“Object Editor”); // Create a window called “Hello, world!” and append into it.

ImGui::Text("This is some useful text.");               // Display some text (you can use a format strings too)
														//ImGui::Checkbox("Demo Window", &show_demo_window);      // Edit bools storing our window open/close state

ImGui::Checkbox("Activate BoundingBox", &BoundingBox);

if (BoundingBox)
{
	printf("on and off");
}
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);            // Edit 1 float using a slider from 0.0f to 1.0f
//ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color

if (ImGui::Button("Button")) {                            // Buttons return true when clicked (most widgets return true when edited/activated)
	counter++;
	printf("hello");

}
ImGui::SameLine();
ImGui::Text("counter = %d", counter);

ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);


ImGui::End();

InmediateUI:

bool InmediateUI::Initialize(SDL_Window * window_, SDL_GLContext context_)
{

glsl_version = "#version 330";
window = window_;
context = context_;

if (window == nullptr) {
	std::cout << "issue in window  " << std::endl;
}
if(context == nullptr)
	std::cout << "issue in context" << std::endl;
else {/*std::cout << "we good fam" << std::endl;*/ }


clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);

IMGUI_CHECKVERSION();
ImGui::CreateContext();
io = ImGui::GetIO(); (void)io;//for fonts

// Setup Platform/Renderer bindings //check for proper init
if (!ImGui_ImplSDL2_InitForOpenGL(window, context)) { return false; }

if (!ImGui_ImplOpenGL3_Init(glsl_version)) { return false; }
ImGui::StyleColorsDark(); 

//SDL_PollEvent();takes poll events to sync it later

ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplSDL2_NewFrame(window);
ImGui::NewFrame();

//Initial ui state 
UIstate = GameState::Main_Menu;	

return true;

}

Render(){

ImGui::EndFrame();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

}

if you could point me in the right direction it would be really appreciated :slight_smile:

Thanks a lot


#2

Hard to tell without more context. We don’t see what “polymorphism” has to do with it.
Maybe provide some gif and a complete application.


#3

I fixed it ;), It was my error