Immediate-Mode-UI / Immediate-Mode-UI/Nuklear
Handling Custom Input
- Dominant language
- C
- Stars
- 11.4k
- Forks
- 686
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 3
Description
Hi, first off, this is a great project!
I've been searching for a way to handle custom text input, specifically keyboard input when you're not focused on any particular widget.
For example, if I have a couple of text boxes (say, `nk_edit_string`) stacked vertically, I'd like for a new one to be created, appended to the top, and focused on on keyboard input if there is nothing currently active, otherwise handle input in the active widget (i.e. if I press "e" with nothing focused, I want to see a new `nk_edit_string` at the top of my window with an "e" in its buffer).
I am aware of `nk_item_is_any_active`, so I've been bashing my head trying to figure out how to handle input otherwise.
I'm currently using the d3d11 demo as a base, and I have
```c
MSG msg;
nk_input_begin(ctx);
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT) running = 0;
else if (msg.message == WM_KEYDOWN) nk_input_key(ctx, msg.wParam, 1);
else if (msg.message == WM_KEYUP) nk_input_key(ctx, msg.wParam, 0);
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
nk_input_end(ctx);
```
, but I'm stuck on what to do after `nk_input_key`.
Any help would be greatly appreciated!
Contributor guide
Research direction
Start by reading the d3d11 demo's input loop and the behavior around nk_input_key and nk_item_is_any_active. Clarify how unfocused keyboard input should create and focus a new nk_edit_string, then determine the expected behavior for input already handled by an active widget; the issue does not name a target file or test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100