-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnuklear_console_sdl.h
More file actions
44 lines (40 loc) · 1.16 KB
/
nuklear_console_sdl.h
File metadata and controls
44 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef NK_CONSOLE_SDL_H__
#define NK_CONSOLE_SDL_H__
#if defined(__cplusplus)
extern "C" {
#endif
/**
* Call once per frame after rendering to sync SDL text input state with the
* active console widget. Starts text input when a textedit field is active,
* stops it otherwise.
*
* Compatible with both SDL2 and SDL3. For SDL2, window may be NULL.
*/
NK_INTERN void nk_console_sdl_update_text_input(nk_console* console, SDL_Window* window) {
nk_console* top = nk_console_get_top(console);
nk_console_top_data* top_data = (nk_console_top_data*)top->data;
nk_console* active = (top_data->active_parent != NULL)
? top_data->active_parent->activeWidget
: NULL;
nk_bool wants_text = (active != NULL && active->type == NK_CONSOLE_TEXTEDIT_TEXT);
if (wants_text) {
#if SDL_MAJOR_VERSION >= 3
SDL_StartTextInput(window);
#else
(void)window;
SDL_StartTextInput();
#endif
}
else {
#if SDL_MAJOR_VERSION >= 3
SDL_StopTextInput(window);
#else
(void)window;
SDL_StopTextInput();
#endif
}
}
#if defined(__cplusplus)
}
#endif
#endif /* NK_CONSOLE_SDL_H__ */