Skip to content

A problem about ImGui::Selectable with using Linknode #2667

@kwangsing3

Description

@kwangsing3

Platform: Windows10
Using: opengl3
defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
#include <glad/glad.h>

Sorry, but I had read many bunch of questions about how to dynamic add items to listbox or combo, follow those examples, I failed once and once again.

Now, I trying to do that with Linknode, it doesn't work perfectly, but I do not understand why,
and I opened a new place, sorry about that :P

Here is the code I copied and edited from ImGuiDemo.cpp to my GUI.

struct listbool
{
	bool selected=false;
	listbool* next=NULL;
};

static listbool _headlistbool;
static listbool *_currentlistbool = &_headlistbool;
if (SceneManager::Objects.size() > 0)
{
	_currentlistbool = &_headlistbool;
	//static bool selection[5] = { false, false, false, false, false };
	for (int n = 0; n < SceneManager::Objects.size(); n++)
	{
		char buf[32];
		sprintf(buf, SceneManager::Objects[n]->transform.name, n);
		if (ImGui::Selectable(buf, _currentlistbool->selected))
		{
		//	if (!ImGui::GetIO().KeyCtrl)    // Clear selection when CTRL is not held
			//	Clear_ListBool(_headlistbool);
			_currentlistbool->selected =!_currentlistbool->selected;
		}
		if (_currentlistbool->next == NULL)
			_currentlistbool->next = new listbool();
		_currentlistbool = _currentlistbool->next;
	}	
}
else
	_currentlistbool->next = NULL;

Here's the video: https://youtu.be/tvHkQp5C0zw

---Update---
If I just using array, it works fine normally, I found that, this code couldn't be triggered, (except the first objects of them)
https://imgur.com/OumfQi1

if (ImGui::Selectable(buf, _currentlistbool->selected))
{
    _currentlistbool->selected =!_currentlistbool->selected;
}

Thanks and sorry, again :q

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions