Skip to content

Conversation

ViteiHeckel
Copy link

Otherwise, the ActiveId may be reset to 0 before we have a chance to get pressed returned as true.

…rue.

Otherwise, the ActiveId may be reset to 0 before we have a chance to get pressed returned as true.
@ocornut
Copy link
Owner

ocornut commented May 22, 2015

This looks incorrect. ActiveId needs to be released by the button when the mouse button is released. What use case are you trying to solve?

@ViteiHeckel
Copy link
Author

When we have several InputInt widgets lined up in a row, each with a single int value displayed so as to show the - and + buttons, those buttons do not apply the new value to the int on anything beyond the first InputInt. When the ActiveId was cleared on what was line 4590 without having set pressed to true due to hovered being false, we were never able to have pressed set to true when (repeat && g.ActiveId && ImGui::IsMouseClicked(0, true)) because ActiveId had already been cleared. We are therefore never getting into the handling for when ImGui::Button("+", button_sz, true) was supposed to return true.

@ocornut
Copy link
Owner

ocornut commented May 22, 2015

My guess is that you have id collisions (the way id work gets obvious once you understand how the library works but may not be initially.)

If you have multiple widget with the same visible label, they mush be differentied via a manipulation of the id stack (generally pushid/popid) or specifying an extra id within the label ("label##extra"). Read the segment about label/id in the FAQ it should be all explained there. If you have a known amount of widgets it may be simplier to add the extra identifier in the label "add##x" "add##y" etc. if you are creating them from a loop or from data using PushId/PopId probably makes more sense and is more convenient.

let me know if that's your problem or if there's actually a problem with the button.

(It is in my todo list to add a system to notify the user non-agressively of id collisions.)

@ViteiHeckel
Copy link
Author

Yes, apparently it was an id collision. Making the labels unique alleviated the issue. Perhaps the way ids are assigned could be modified to assign unique ids to widgets even with identical labels.

@ocornut
Copy link
Owner

ocornut commented Jun 2, 2015

That would be more dependent on the ui state (e.g. widget number, or create sequence from collisions - easier said than done without affecting CPU cost) and therefore ID would be less stable which is not desired. In the case of having very dynamic layout, e.g. you are displaying the live state of your game/engine you want things like open/closed tree nodes to be stable and preserve their state.
More over I think it will detract people from understanding how the library and ID stack work, which is essential to many things, so it'll be weird to try to hide it.

However, I have a plan to make a system to visually notify the programmer of ID collisions, so that would direct you fairly fast to the right usage way.

@ViteiHeckel ViteiHeckel closed this Jun 2, 2015
idbrii added a commit to idbrii/cpp-imgui that referenced this pull request Mar 24, 2025
Includes my merged PRs and everything in my dev branch. Haven't tested
with it yet.

Changelog:
Test case for clip rect
HACK: more recent Windows SDK and VS2017; disable graph
Set size to amount of space required
Merge pull request ocornut#349 from maksw2/master
Merge pull request ocornut#347 from mgerhardy/341
Merge pull request ocornut#348 from mgerhardy/fixed-warning
Merge pull request ocornut#346 from mgerhardy/280
Merge pull request ocornut#345 from mgerhardy/322
Merge pull request ocornut#344 from rherilier/fix-gcc-warnings
Merge pull request ocornut#336 from rherilier/add-isusingviewmanipulate
Merge pull request ocornut#335 from RedSkittleFox/alternative_window
Merge pull request ocornut#334 from ocornut/fix-beginchildframe
dear imgui update and small fixes
Merge pull request ocornut#316 from Batres3/2DSupport
Merge pull request ocornut#326 from Sayama3/use-push-pop-id
Merge pull request ocornut#328 from georgeto/master
Merge pull request ocornut#330 from maritim/master
Merge pull request ocornut#331 from GiovanyH/patch-1
Merge pull request ocornut#318 from dougbinks/imgui_math_operators
Merge pull request ocornut#312 from kimidaisuki22/master
div 0 fixed
Merge pull request ocornut#301 from ZingBallyhoo/using-any
Merge pull request ocornut#300 from Clog41200/Configurable-limits
Merge pull request ocornut#298 from xDUDSSx/fix/rotation_circles
Merge pull request ocornut#297 from xDUDSSx/fix/vertical-aspect-scaling
Merge pull request ocornut#289 from ComputationalBiomechanicsLab/fix_isusing-ignores-setid
Merge pull request ocornut#291 from ocornut/fix_math_operators_include
Merge pull request ocornut#282 from MohitSethi99/master
Merge pull request ocornut#276 from pthom/virtual_destructors
Merge pull request ocornut#271 from idbrii/clip-parent
Merge pull request ocornut#270 from idbrii/btn-behaviour
Merge pull request ocornut#265 from mgerhardy/pr/fix-minor-formatting
Merge pull request ocornut#264 from mgerhardy/pr/div0
Merge pull request ocornut#269 from peter1745/hatched-line-thickness-enhancement
Merge pull request ocornut#259 from miyanyan/master
Merge branch 'master' of https://github.com/CedricGuillemet/ImGuizmo
update dear imgui
Merge pull request ocornut#256 from Aidiakapi/patch-1
Merge pull request ocornut#252 from aaronkirkham/master
Merge pull request ocornut#249 from rokups/rk/mouse-capture
Merge pull request ocornut#246 from mgerhardy/pr/viewmanipulate
removed commented code
fix click view cube
Merge pull request ocornut#231 from mgerhardy/master
Merge pull request ocornut#230 from mgerhardy/master
Merge pull request ocornut#228 from longod/master
Merge pull request ocornut#227 from madeso/master
AddBezierCubic
Merge pull request ocornut#226 from sherief/master
revert culling test commit
Merge pull request ocornut#203 from rokups/rk/misc-fixes
Merge pull request ocornut#212 from zhaijialong/fix-behind-camera-cull
Merge pull request ocornut#209 from VictorFouquet/fix_normalize
scale is always local
Merge pull request ocornut#202 from pezy/master
imguizmo namespace
Merge pull request ocornut#194 from JonathanHiggs/vcpkg-example
1.84 WIP
Merge pull request ocornut#197 from idbrii/seq-btn-color
Merge pull request ocornut#196 from idbrii/seq-big-handles
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

Successfully merging this pull request may close these issues.

2 participants