Skip to content

Separate property focus from text edit focus - #993

Merged
RobLoach merged 2 commits into
Immediate-Mode-UI:masterfrom
snowyukitty:fix/edit-property-focus
Oct 31, 2026
Merged

RobLoach merged 2 commits into
Immediate-Mode-UI:masterfrom
snowyukitty:fix/edit-property-focus

Conversation

@snowyukitty

@snowyukitty snowyukitty commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #974.

Activating a property sets win->edit.active without assigning a text-edit identity. On the next frame, the first or previously focused text edit can regain focus and consume the property's keyboard input.

Keep property focus in win->property, and have the SDL3 renderer request text input for either an active text edit or property, including popups. This preserves the SDL3 text-input behavior introduced in c4e370b without sharing widget focus. The generated header is rebuilt and the patch version is bumped as requested by the contribution guide.

The standalone repro demo has been removed from the PR to keep the shipped change focused. Validation still uses the headless harness retained in the earlier commit, restored temporarily against the current source. It covers both widget orders, string and buffer text edits, all six property entry points, committing a value when focus moves, and returning to the property.

Validation on Linux, rerun for this follow-up:

  • The retained regression passes all 24 scenarios as C89, C++11, and with AddressSanitizer/UndefinedBehaviorSanitizer. The same harness fails 12 scenarios on the unchanged upstream base.
  • From the repository root, make nuke reproduces the checked-in header and sh -e .github/ci_compile_sources.sh compiles all 43 source files.
  • A local SDL3 3.2.24 smoke using dummy video and the real software renderer verifies text-input activation, correct property typing, and deactivation after blur in both a normal window and a popup.

The regression build retains two existing unused-function warnings. Other platform/backend demos and live OS IME behavior were not run locally. Upstream workflows currently require maintainer approval before execution.

@RobLoach RobLoach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty good. Couple questions.

Comment thread demo/repro_edit_property/main.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the little text case here, but do we need it?

active = ctx->active->popup.win->edit.active || ctx->active->popup.win->property.active;
else
active = ctx->active->edit.active;
active = ctx->active->edit.active || ctx->active->property.active;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any other renderers where this happens?

@snowyukitty

Copy link
Copy Markdown
Contributor Author

Thanks! Removed the standalone repro demo in c3877b5 to keep the PR focused. I retained it for local validation: all 24 scenarios still pass as C89, C++11, and with AddressSanitizer/UndefinedBehaviorSanitizer.

The focus mix-up originates in the shared property code. I checked the demo backends: only sdl3_renderer uses the window edit-focus flag to start/stop platform text input, so that adapter also needs to check property focus. The real SDL3 renderer's normal-window and popup paths both pass. Other backend demos and live OS IME behavior were not run locally.

@RobLoach RobLoach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me, I'll leave this open for anyone else to review too.

@RobLoach
RobLoach merged commit f101764 into Immediate-Mode-UI:master Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nk_edit_* and nk_property_* both get cursor focus when used next to each other

2 participants