aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-07 06:30:59 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-07 06:30:59 +0100
commit214336492da0d184d5ad4ac64c31920954c5f7e7 (patch)
treeebcb9e7ace6022f7afe383f1aea986260fffd09f /tests
parentcb679636f77fe2a03e8dab3a511e28e1ab898316 (diff)
Implement text input
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c17
1 files changed, 15 insertions, 2 deletions
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});