Comments (5)
use ImGui::SetNextItemAllowOverlap()
before selectable
When multiple widgets fight over same interactive air-space ( selectable and button in this case ), first one that is encountered consumes action by default( selectable ). You can change this behaviour by allowing overlap on item that consumed your actions with side-effect that click action will be delayed by a frame
from imgui.
Do you know what makes my code special? This doesn't seem to be used in the advanced table demo.
Because in Advanced
table demo Selectable is submited with: ImGuiSelectableFlags_AllowOverlap
flag which enables same behaviour as calling ImGui::SetNextItemAllowOverlap()
ImGuiSelectableFlags selectable_flags = (contents_type == CT_SelectableSpanRow) ? ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap : ImGuiSelectableFlags_None;
if (ImGui::Selectable(label, item_is_selected, selectable_flags, ImVec2(0, row_min_height)))
from imgui.
I could be completely wrong here and there's ofcourse something I'm doing that's wrong with the selectable row. Seems like it's eating the click or something. I can only get it to work if I get a button on a different line.
Here's the complete code for the table.
void game::show_data_explorer_debug_window(Game_State* state) {
if (!ImGui::Begin("Data Explorer", &state->tools_.data_explorer_.show_)) {
ImGui::End();
return; // early out
}
auto table_flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg;
auto table_outer_size = ImVec2(0.0f, ImGui::GetTextLineHeightWithSpacing() * 8);
static ImGuiTextFilter filter;
filter.Draw();
// ImGui::SameLine();
if (ImGui::Button("Clear")) {
filter.Clear();
}
// todo: scratch allocator
List<int> filtered = { .allocator_ = state->frame_allocator_ };
defer (filtered.destroy());
for (int i = 0; i < (int)Asset_Table_Size; i += 1) {
const Asset& asset = Asset_Table[i];
if (filter.PassFilter(asset.path_.begin(), asset.path_.end())) {
filtered.add(i);
}
}
if (ImGui::BeginTable("Assets Table", 2, table_flags, table_outer_size)) {
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("Path", ImGuiTableColumnFlags_None, 0, 0);
ImGui::TableSetupColumn("Mem", ImGuiTableColumnFlags_WidthFixed, 100, 1);
ImGui::TableHeadersRow();
ImGuiListClipper clipper;
clipper.Begin((int)filtered.size());
while (clipper.Step())
{
for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++)
{
auto& asset = Asset_Table[filtered[row]];
ImGui::PushID(row);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
bool is_selected = state->tools_.data_explorer_.selected_asset_ == &asset;
if (ImGui::Selectable(asset.path_.begin(), &is_selected, ImGuiSelectableFlags_SpanAllColumns)) {
state->tools_.data_explorer_.selected_asset_ = &asset;
}
// don't know if we need these, maybe it's enough to just do filename
ImGui::TableSetColumnIndex(1);
ImGui::Text("%zu", asset.data_.size()); // Size of this asset in memory, if it is zero then it is not loaded.
// Does not work, will render button non-interactable.
ImGui::SameLine();
if (0 < asset.data_.size()) {
if (ImGui::SmallButton("Reload")) {
// ...
}
} else {
if (ImGui::SmallButton("Load")) {
OR_ABORT(load_asset(&asset));
}
}
ImGui::PopID();
}
}
ImGui::EndTable();
}
ImGui::End();
}
from imgui.
Tried 1.90.8 unfortunately it didn't fix my issue.
from imgui.
use
ImGui::SetNextItemAllowOverlap()
before selectable
@lukaasm Great, thanks this works 👍Do you know what makes my code special? This doesn't seem to be used in the advanced table demo.
from imgui.
Related Issues (20)
- Position inside child window when border width changes HOT 7
- Left upper corner coordinates and child window dimensions for different border thicknesses HOT 3
- InputText display latency when trickling events HOT 4
- ImGui::Image tint_col doesn't allow amplifying texture color intensity HOT 1
- ImGuiListClipper for horizontal lists HOT 2
- 10 years of Dear ImGui (long post) HOT 33
- How can I render a large number of waveforms drawn using ImGui's drawList only once and then use it as a cached image for display to reduce drawing resource usage? Should I use a texture with DirectX 11 and Win32, or save it as an image? HOT 2
- Cannot draw inside a very small child window HOT 1
- Can't get ImGui::Shortcut to work HOT 18
- doc: mistake in comment HOT 1
- Support char 'x' for ImGuiInputTextFlags_CharsHexadecimal
- SetCorsorPos - does not work correctly! HOT 8
- Problem with `PushFont` and `PopFont` with menus HOT 4
- Persian / Arabic font support HOT 1
- New SDL3 callbacks example HOT 2
- Please add support for std::bitset in CheckboxFlags. HOT 3
- where is imgui_impl_glfw_gl3.cpp in the latest version HOT 1
- Being able to dock by dragging from any empty space within ImGui window, not only title bar HOT 5
- Information about vertical scroll of InputTextMultiline HOT 2
- Context menu on docked window tab HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgui.