diff options
author | David Robillard <d@drobilla.net> | 2019-08-17 20:50:20 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-09-07 09:51:48 +0200 |
commit | 7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf (patch) | |
tree | 0f885354b2d75875003401379d5aaf9aadda226f /test | |
parent | 27e43183d89aad98f6000ee187b05547776ae4c2 (diff) | |
download | pugl-7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf.tar.gz pugl-7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf.tar.bz2 pugl-7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf.zip |
Add clipboard support
Diffstat (limited to 'test')
-rw-r--r-- | test/pugl_test.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/test/pugl_test.c b/test/pugl_test.c index ee58cf8..4bd5f80 100644 --- a/test/pugl_test.c +++ b/test/pugl_test.c @@ -147,7 +147,7 @@ swapFocus(PuglTestApp* app) } static void -onKeyPress(PuglView* view, const PuglEventKey* event) +onKeyPress(PuglView* view, const PuglEventKey* event, const char* prefix) { PuglTestApp* app = (PuglTestApp*)puglGetHandle(view); PuglRect frame = puglGetFrame(view); @@ -156,6 +156,14 @@ onKeyPress(PuglView* view, const PuglEventKey* event) swapFocus(app); } else if (event->key == 'q' || event->key == PUGL_KEY_ESCAPE) { app->quit = 1; + } else if (event->state & PUGL_MOD_CTRL && event->key == 'c') { + puglSetClipboard(view, NULL, "Pugl test", strlen("Pugl test") + 1); + fprintf(stderr, "%sCopy \"Pugl test\"\n", prefix); + } else if (event->state & PUGL_MOD_CTRL && event->key == 'v') { + const char* type = NULL; + size_t len = 0; + const char* text = (const char*)puglGetClipboard(view, &type, &len); + fprintf(stderr, "%sPaste \"%s\"\n", prefix, text); } else if (event->state & PUGL_MOD_SHIFT) { if (event->key == PUGL_KEY_UP) { frame.height += 10; @@ -220,7 +228,7 @@ onParentEvent(PuglView* view, const PuglEvent* event) } break; case PUGL_KEY_PRESS: - onKeyPress(view, &event->key); + onKeyPress(view, &event->key, "Parent: "); break; case PUGL_MOTION_NOTIFY: break; @@ -252,7 +260,7 @@ onEvent(PuglView* view, const PuglEvent* event) app->quit = 1; break; case PUGL_KEY_PRESS: - onKeyPress(view, &event->key); + onKeyPress(view, &event->key, "Child: "); break; case PUGL_MOTION_NOTIFY: app->xAngle = fmodf(app->xAngle - (float)(event->motion.x - app->lastMouseX), 360.0f); |