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

Feature request: PushBehaviour to change widget return and buffer write out behaviour #2060

Closed
LAK132 opened this issue Sep 4, 2018 · 2 comments

Comments

@LAK132
Copy link

LAK132 commented Sep 4, 2018

Version/Branch of Dear ImGui:
1.64


As per the later discussion in #2006, would it be possible to change the return behaviour of some widgets with something like PushStyleVar?
Say if you did ImGui::PushBehaviour(ReturnBehaviourFlags_ReturnTrueOnChange) it made widgets return true every change, but ImGui::PushBehaviour(ReturnBehaviourFlags_ReturnTrueOnComplete) made them only return true when the user is finished modifying the value. This method could reduce the number of flags needed for each widget type and possibly remove the need for IsItemDeactivatedAfterEdit().
It might also be interesting to use this to change how and when values are written out from their buffers, potentially reducing the number of resize() calls in the std::string version of ImGui::InputText

@ocornut
Copy link
Owner

ocornut commented Sep 4, 2018

OK you are slightly diverging from the thing discussed in #2006.
There are multiple topics there:

  • Let's focus on the needs rather than building an issue out of a hypothetical API call.

  • As I pointed out in Allow for dynamic re-allocation of internal buffer while user is still typing in InputText? #2006, this may working for you only because you have an (unnecessary, but here happens to be helpful) indirection and sync between your data and the imgui data handled by imgui. The fundamental design of dear imgui revolve around removing those duplication/sync. And you probably don't have this indirection for all your widgets, so how would ReturnBehaviourFlags_ReturnTrueOnComplete effectively be useful and meaningful when you are editing Checkbox, Integers etc where the underlying value is already modified while editing?

  • Suggesting a global all-items flags is much more work that supporting it for InputText(). A) IsItemDeactivatedAfterEdit() is a costlier function and B) we currently can't guarantee it works with every use case.

The idea needs to be supported with more examples. Right now your stance is "it is annoying to call IsItemDeactivatedAfterEdit() I want it by default everywhere" can you support that claim with more examples than InputText and how it would work? (Remember that the definition you are asking for is not correlated to the writing back of value)

It might also be interesting to use this to change how and when values are written out from their buffers, potentially reducing the number of resize() calls in the std::string version of ImGui::InputText

There's two different things here. A) Reducing the number of resize() is a non-issue, you have a user callback and you are free to reserve ahead if you need. B) The timing of writing back out to the user's buffer is the topic in #701 I agree it's an important/useful feature and I agree there's overlap between that and this topic hypothetical ReturnBehaviourFlags_ReturnTrueOnComplete, perhaps there's a single behavior enum that encompass both strategy.

@ocornut
Copy link
Owner

ocornut commented Mar 15, 2021

Closing this as stale (and ihmo answered).

@ocornut ocornut closed this as completed Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants