From 214336492da0d184d5ad4ac64c31920954c5f7e7 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 7 Nov 2021 06:30:59 +0100 Subject: Implement text input --- tests/main.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/main.c b/tests/main.c index 3ead877..85754f2 100644 --- a/tests/main.c +++ b/tests/main.c @@ -51,7 +51,7 @@ static void draw(mgl_window *window, void *userdata) { u->fps_counter = 0; } char str[255]; - snprintf(str, sizeof(str), "fps: %d", u->fps); + snprintf(str, sizeof(str), "hello|world\nfps: %d", u->fps); mgl_text text; mgl_text_init(&text, u->font, str, strlen(str)); @@ -216,7 +216,20 @@ int main(int argc, char **argv) { mgl_event event; while(mgl_window_is_open(&window)) { while(mgl_window_poll_event(&window, &event)) { - + switch(event.type) { + case MGL_EVENT_TEXT_ENTERED: { + fprintf(stderr, "text event, codepoint: %u\n", event.text.codepoint); + break; + } + case MGL_EVENT_KEY_PRESSED: { + fprintf(stderr, "key press event, code: %u\n", event.key.code); + break; + } + case MGL_EVENT_KEY_RELEASED: { + fprintf(stderr, "key release event, code: %u\n", event.key.code); + break; + } + } } mgl_window_clear(&window, (mgl_color){0, 0, 0, 255}); -- cgit v1.2.3