Skip to content

Is there any way to check whether a window has just been made active? #1061

@haferburg

Description

@haferburg

In response to user input I am creating a window that has an InputText. I would like the text to automatically starts out as selected when the window pops up, so I want to call SetKeyboardFocusHere, but only if the window has not been visible (active(?)) before.

This hack seems to do the trick:

bool ImGui::WindowWasActive(const char* name) {
  ImGuiWindow* window = FindWindowByName(name);
  return window != 0 && (window->WasActive || window->Active);
}

Is there an official way of doing this? Adding an optional bool* parameter to Begin might be cleaner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions