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

Reliable way to get active Table row(cell) #8443

Open
friflo opened this issue Feb 27, 2025 · 0 comments
Open

Reliable way to get active Table row(cell) #8443

friflo opened this issue Feb 27, 2025 · 0 comments
Labels
focus nav keyboard/gamepad navigation

Comments

@friflo
Copy link

friflo commented Feb 27, 2025

Version/Branch of Dear ImGui:

Version 1.91.6.1, ImGui.NET

Back-ends:

imgui_impl_sdl3.cpp + imgui_impl_wgpu.cpp

Compiler, OS:

Windows 11 - .NET 8

Full config/build information:

No response

Details:

Question:

hi,

My goal is to show the entity properties of the active entity (row) in an "Explorer" (Table) window within another "Inspector" window. See attached Video.
The selected entity in Inspector should change only by using the keyboard arrow keys in the Explorer table.

My general approach is using IsItemFocused().

It works as expected if the cell contains a simple widget like InputText() or InputFloat().
In this case IsItemFocused() == 1 if the cell is selected (has a rectangle arround).

In case of InputFloat3() not. Only when starting to edit its fields.

While in general it possible by using IsItemFocused() to achieve the goal.
It would be much simpler in case the API would return the active cell via an API.
E.g. TableGetActiveCell(int* row, int* column).

btw: Nice project!

Screenshots/Video:

Table-Active-Cell.mp4

Minimal, Complete and Verifiable Example code:

ImGui.InputText("##field", ref value);
ImGui.IsItemFocused(); // value after pressing escape: 1

ImGui.InputFloat3("##field", ref value);
ImGui.IsItemFocused(); // value after pressing escape: 0

This behavior can be checked in imgui_demo.cpp at
Widgets > Querying Item Status (Edited/Active/Hovered etc.)

Test 1 - InputText

  • Select: InputText
  • Click in InputText Widget
  • Press Escape

Result: IsItemFocused() = 1

Test 2 - InputFloat3

  • Select: InputFloat3
  • Click in InputFloat3 Widget
  • Press Escape

Result: IsItemFocused() = 0

@ocornut ocornut added nav keyboard/gamepad navigation focus labels Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus nav keyboard/gamepad navigation
Projects
None yet
Development

No branches or pull requests

2 participants