Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a string with a % to SetTooltip() causes garbage data to be printed #442

Open
shayded-exe opened this issue Nov 1, 2023 · 3 comments

Comments

@shayded-exe
Copy link

shayded-exe commented Nov 1, 2023

image

image

ImFormatStringV

If vsnprintf interprets the string passed to SetTooltip as a format string, it looks at va_list args which will always be empty. The result is the next pointer being formatted into the string.

ImGui.NET should allow for passing additional args to SetTooltip to allow the arg to actually be used as a format string.

@shayded-exe
Copy link
Author

I did just realize that a workaround is to escape the % with an additional % like this:
var str = $"{value:p1}% - {label}";

@shayded-exe shayded-exe changed the title Passing a string with a % to Text() causes garbage data to be printed Passing a string with a % to SetTooltip() causes garbage data to be printed Nov 1, 2023
@zaafar
Copy link
Collaborator

zaafar commented Nov 3, 2023

yeah, that's how it is, if you wanna read more about it there was a recent discussion about it over here.
dearimgui/dear_bindings#45

@shayded-exe
Copy link
Author

Ah I see.

Not a big deal since it can easily be worked around, but it would be nice if this issue had higher visibility so future people like me don't spend a couple hours in confusion :)

Maybe I could do a PR to start adding a "known gotchas" section to the docs to highlight oddities like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants