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)
- DX12 backend can't render into a multisampled frame buffer HOT 1
- Question: fine-tuning the window scrollbar HOT 5
- Trying to get a 3 part rendering pipeline working but events aren't processed. HOT 3
- Are there ImGui APIs that can throw? HOT 3
- Unable to checkout v1.89.8 from Jetbrains IDE using tag HOT 2
- Question: GetCurrentWindow internal function HOT 3
- LabelText can't auto set item size
- Mouse action functions (IsItemHovered, IsMouseClicked,IsMouseDown,IsMouseReleased, etc.) always return false for overlapped item. HOT 10
- Hang when destroying viewports in example_sdl2_opengl3 (only when vsync is deactivated) HOT 6
- Imgui for arm64
- Question: Auto tile panels HOT 1
- Weird ImGui::InputText behavior when encapsulated inside a struct HOT 3
- `WantSetMousePos` warping leaks mouse events from previous position into next frame HOT 3
- BeginDisable doesn't disable shortcuts HOT 2
- Latest SDL3 API removed keysym field in SDL_Keyboardevent
- Menu window size is erroneously clamped to main viewport size HOT 4
- Wrong "Number of Segment" value in Demo Window. HOT 1
- Meta + [key] on macOS using emscripten is broken (sdl2 + glfw backends) HOT 3
- Dragging secondary viewports out of main viewport HOT 5
- Latest SDL API breaks build - The text input state has been changed to be window-specific HOT 2
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.