Selectable capturing click and not forwarding to other widgets #517

Closed
opened 2016-02-02 16:55:25 +00:00 by itamago · 3 comments
itamago commented 2016-02-02 16:55:25 +00:00 (Migrated from github.com)

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

Hello, I have a question regarding 'Selectable' : I use it to select a full line in a table (please see the capture below). <img width="1303" alt="screen shot 2016-02-02 at 17 51 35" src="https://cloud.githubusercontent.com/assets/16628136/12756841/d42134ea-c9d5-11e5-9f98-05ee3bd46c35.png"> 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 commented 2016-02-02 18:20:09 +00:00 (Migrated from github.com)

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.
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 commented 2016-02-02 19:38:20 +00:00 (Migrated from github.com)

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 :)

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 :)
ocornut commented 2023-06-28 13:14:06 +00:00 (Migrated from github.com)

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

See this comment for details: https://github.com/ocornut/imgui/issues/6512#issuecomment-1611369198

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.
I have pushed a bunch of changes related to AllowOverlap mode. See this comment for details: https://github.com/ocornut/imgui/issues/6512#issuecomment-1611369198 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.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#517
No description provided.