Skip to content

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

@friflo

Description

@friflo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    focusnavkeyboard/gamepad navigation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions