diff options
| author | Arslaan Pathan <[email protected]> | 2026-05-01 21:38:49 +1200 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2026-05-01 21:38:49 +1200 |
| commit | 6ad244502d1c3c09a26012c5e7fad901c95cc38e (patch) | |
| tree | b0b8106fca78a49e47313f35d8245eeb6980d3ac /tests/test_hooks.c | |
| parent | ccb8f9316c9bc7aded2dd5d74d2e82445bf2f647 (diff) | |
| download | saffron-6ad244502d1c3c09a26012c5e7fad901c95cc38e.tar.xz saffron-6ad244502d1c3c09a26012c5e7fad901c95cc38e.zip | |
Fix the buttons and implement hooks for future webkit bindings to build on top of
Diffstat (limited to 'tests/test_hooks.c')
| -rw-r--r-- | tests/test_hooks.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_hooks.c b/tests/test_hooks.c new file mode 100644 index 0000000..ad56aa9 --- /dev/null +++ b/tests/test_hooks.c @@ -0,0 +1,36 @@ +#include "saffron_api.h" +#include <saffron.h> +#include <SDL3/SDL.h> +#include <stdio.h> + +bool hook_callback(SDL_Event* event) { + printf("got an event!\n"); + return false; // we didnt consume the event +} + +bool hook_callback_2(SDL_Event* event) { + printf("second hook got an event!\n"); + return true; // we consumed the event +} + +bool hook_callback_3(SDL_Event* event) { + printf("you should never see this, a hook with higher priority (hook_callback_2) should have consumed this event\n"); + return false; +} + +int main() { + saffron_init(); + + SaffronWindow* window = saffron_window_new("Saffron hooks test", 800, 600); + + saffron_hook_sdl_all_events(window, hook_callback, 999); + saffron_hook_sdl_all_events(window, hook_callback_2, 2); + saffron_hook_sdl_all_events(window, hook_callback_3, 1); + + saffron_window_main(window); + + saffron_window_free(window); + saffron_quit(); + + return 0; +} |
