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

Selectable capturing click and not forwarding to other widgets #517

Closed
itamago opened this issue Feb 2, 2016 · 3 comments
Closed

Selectable capturing click and not forwarding to other widgets #517

itamago opened this issue Feb 2, 2016 · 3 comments
Labels

Comments

@itamago
Copy link

itamago commented Feb 2, 2016

Hello,

I have a question regarding 'Selectable' : I use it to select a full line in a table (please see the capture below).

screen shot 2016-02-02 at 17 51 35

As Selectable capture the mouse-click, all the other widgets don't react anymore to the mouse clic ; I cannot enable/disable checkboxes, I cannot expand combo, etc.

Does someone know a simple way to make Selectable forward the mouse-click event instead of capturing it ?

Thanks for your help

@ocornut
Copy link
Owner

ocornut commented Feb 2, 2016

So this a little tricky.
Do you want to have the line selected when a checkbox/combo is used?
Are you using selectable just as a visual aid or a permanent selection?

  • So, here you are using a Selectable that spans all the line coverage.
    If you call SetItemAllowOverlap() after Selectable() other items will be usable. However in this context Selectable() will react to mouse-release, so if another widget is active (e.g. clicked on the checkbox) it'll steal activity from the Selectable and as a result Selectable won't return true.
    If you want the line selection to happens you can set the selection yourself when the other widgets are activated. You'd need to include imgui_internal.h to use SetItemAllowOverlap() but I've been considering moving it to imgui.h
  • Another possibility is to not use the SpanAllColumns flag of the selectable.
  • Another possibility would be to request Selectable() to draw spanning all columns but only handle interaction on the first column (if that is an acceptable behaviour for you). We'd need to expose this option to Selectable in some way. I could invesgigate that for you if you want.

@itamago
Copy link
Author

itamago commented Feb 2, 2016

Thank you very much !
Calling SetItemAllowOverlap() just after Selectable() provides a behaviour better than the one I expected.
I'm able to select a line and continue to modify another line at the same time. Perfect :)

@itamago itamago closed this as completed Feb 2, 2016
ocornut added a commit that referenced this issue Jun 27, 2023
ocornut added a commit that referenced this issue Jun 28, 2023
…'ImGuiTreeNodeFlags_AllowOverlap', 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'. Kept redirecting enums (will obsolete). (#6512, #3909, #517)

+ Internals: Renamed 'ImGuiButtonFlags_AllowItemOverlap' to 'ImGuiButtonFlags_AllowOverlap' without redirection.
ocornut added a commit that referenced this issue Jun 28, 2023
…temAllowOverlap()'. (#6512, #3909, #517)

# Conflicts:
#	imgui.cpp
#	imgui_widgets.cpp
ocornut added a commit that referenced this issue Jun 28, 2023
…g an item using AllowOverlap mode. Added ImGuiHoveredFlags_AllowWhenOverlappedByItem, ImGuiHoveredFlags_AllowWhenOverlappedByWindow., (#6512, #3909, #517)
ocornut added a commit that referenced this issue Jun 28, 2023
…so it can be called from ButtonBehavior() not following an ItemAdd().

This also allow moving AllowOverlap logic from ButtonBehavior() to ItemHoverable(), allowing other widgets to honor it. (#6512, #3909, #517)
ocornut added a commit that referenced this issue Jun 28, 2023
…r() to ItemHoverable() now that it is possible. (#6512, #3909, #517)

This allows DragXXX, SliderXXX, PlotXXX etc to honor SetNextItemAllowOverlap().
@ocornut
Copy link
Owner

ocornut commented Jun 28, 2023

I have pushed a bunch of changes related to AllowOverlap mode.

See this comment for details: #6512 (comment)

TL;DR;

  • SetItemAllowOverlap() couldn't work since 1.89 and was obsoleted.
  • Introduced SetNextItemAllowOverlap(). It doesn't need an internal button flags and should work across most/all widgets.
  • Made IsItemHovered() aware of this (previously it wasn't) with opt-out flag ImGuiHoveredFlags_AllowWhenOverlappedByItem.
  • Renamed various xxxAllowItemOverlap flags to xxxAllowOverlap.
  • Other things, see link above.

ocornut added a commit that referenced this issue Jul 5, 2023
…#3909, #517)

+ Merge some shallow changes from range-select branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants