AllenDang / giu

Cross platform rapid GUI framework for golang based on Dear ImGui.
MIT License
2.16k stars 128 forks source link

[bug] Button's ID() overrides label text #719

Closed WinPooh32 closed 8 months ago

WinPooh32 commented 8 months ago

What happend?

Set button's label as "label", but its "id", when ID("id") is called.

Code example

main.go ```golang package main import ( g "github.com/AllenDang/giu" ) func loop() { g.SingleWindow().Layout( g.Button("label").ID("id"), ) } func main() { wnd := g.NewMasterWindow("Huge list demo", 800, 600, 0) wnd.Run(loop) } ```

To Reproduce

  1. Run my demo
  2. Button label value is "id".

Version

(latest)

OS

Ubuntu 20.04.6

AllenDang commented 8 months ago

refer the ID policy defined in Imgui, quote from wiki:

Q: So how to set widget's ID manually?
A: Many widgets already implements (*XYZWidget).ID(string) method.

In many widgets its ID is equal to its label (e.g. for Buttons)

Q: But I want to have two buttons with the same label 😕 how to do this?
A: ID (label) consists of two parts - visible and invisible separated by double hash ("##"). For example, "Button##1", will be rendered as "Button". "##Button1" will be rendered as "".