• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Question - ImGui Checkbox question

tervalas

Active member
Joined
Oct 26, 2023
RedCents
386¢
Looking at the reference for ImGui and seeing

Code:
-- Checkbox
---@param label string
---@param value boolean
---@return boolean value, boolean pressed
function ImGui.Checkbox(label, value) end

Trying
Code:
full.selected = ImGui.Checkbox("", full.selected)
because I already have a column header for the checkboxes. But this does not work beyond the first checkbox in the loop (at least for showing the check mark as all this will do is feed a check of ##.selected).

When I put an actual value (ex full.shortname) in instead of "" it works fine. But "" (and I've tried " " too) doesn't seem to want to be acknowledged as a string.

I'll be out of town for a week so won't be able to test responses, but any help would be appreciated.
 
all your checkboxes have the same ID in imgui. Give them unique IDs by either doing some push/pop id, or using ## or ### syntax to override the ID
 
all your checkboxes have the same ID in imgui. Give them unique IDs by either doing some push/pop id, or using ## or ### syntax to override the ID
Have another section that uses the same syntax to create more checkboxes, the only difference is that they call out another value in their table.

Code:
value.selected = ImGui.Checkbox(value.name, value.selected)

Now if what you mean is that by 'label' in the checkbox syntax it means "ID" and therefore it isn't really looking for 'just' any string, I can kind of understand.

For reference, all the .selected values point to a different table with unique entries for each one.

Ex:
Code:
settings = {
  selabj = false,
  selalt = false
}

schools = {
  name = 'Abjuration',
  shortname = 'Abj'
  selected = settings.selabj
}

The loop then ipairs through schools, so full.selected would just be modifying the value in settings.

My main goal is to not have a label on the checkboxes, which the first parameter for the object does.
 
ImGui.Checkbox('', somevalue)

This creates an object in ImGui with ID ''
If you create 10 checkbox that are all visible with ID '', then ImGui can't determine which checkbox is being clicked on properly.

You can either use ImGui.PushID('some id string') and ImGui.PopID() for example when looping over items / in a table, so that each row of the table gets a unique prefix on the IDs, or you can use ## (append the text after ## to the ID) or ### (use the text after ### as the ID).

ImGui.Checkbox('##'..rowIndex, somevalue)
ImGui.Checkbox('###myuniquerowid'..rowIndex, somevalue)

for i=1,10 do
ImGui.PushID(i)
ImGui.Checkbox('', somevalue)
ImGui.PopID()
end
 
Okay thanks, so it is that @param label string doesn't mean any old string. Thank you for pointing out how to still keep it from showing a label too.
 
To keep from cluttering the forums, I'll ask a follow up here.

Code:
ImGui.BeginGroup()
for ...
    statements to loop
end
ImGui.EndGroup()
ImGui.Separator()
ImGui.SameLine(###)
ImGui.Text("test")

I'm trying to get a vertical separator line between the looped content and other things I want to put vertically across (but visually separate).

I've tried putting the separator inside the loop, inside the first group after the loop, tried to make the text it's own group, made the whole 'line' one group, made the separator its own group, etc. I have the text properly horizontally, but no matter what I do I'm getting a horizontal separator bar.
 
To keep from cluttering the forums, I'll ask a follow up here.

Code:
ImGui.BeginGroup()
for ...
    statements to loop
end
ImGui.EndGroup()
ImGui.Separator()
ImGui.SameLine(###)
ImGui.Text("test")

I'm trying to get a vertical separator line between the looped content and other things I want to put vertically across (but visually separate).

I've tried putting the separator inside the loop, inside the first group after the loop, tried to make the text it's own group, made the whole 'line' one group, made the separator its own group, etc. I have the text properly horizontally, but no matter what I do I'm getting a horizontal separator bar.
Pretend it is 1990 and make a table
 
Question - ImGui Checkbox question

Users who are viewing this thread

Back
Top
Cart