S3DW_HANDLE_KEY(3)

πŸ’– S3DW_HANDLE_KEY(3) πŸ’–

okay bestie, welcome to the s3d manual, section 3 (library calls, the fun ones) πŸ’… this one's all about s3dw_handle_key, and honestly? she's a lil legend. let's get into it ✨


🌸 NAME 🌸

s3dw_handle_key β€” handle key input on widget πŸŽ€


✨ SYNOPSIS ✨

#include <s3dw.h>

int s3dw_handle_key(const struct s3d_evt *event);

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, this function is somehow useful to call inside your keyhandler functions if you want your input-boxes to actually, y'know, work. 😌 like, no cap, it's the glue that makes typing into a box not feel broken. the original author even threw in a lil smiley, we love that for them ;) 🫢

here's how you can do it, two ways, pick your fighter:

// way 1:
s3d_set_callback(S3D_EVENT_KEY,s3dw_handle_key);

// way 2:
...
void key(struct s3d_evt *evt)
{
        s3dw_handle_key(evt);
        ....
        // your own keyhandler code
        ...
}
....
s3d_set_callback(S3D_EVENT_KEY,key);

so way 1 is the "just hand it over, I trust you" vibe β€” you set s3dw_handle_key directly as the callback for S3D_EVENT_KEY and let her cook. πŸ‘‘

way 2 is the "I have main character energy and also my own stuff to do" vibe β€” you write your own key function, call s3dw_handle_key(evt) first so the input boxes stay happy, and then drop all your own keyhandler code right after it. πŸ’… then you wire that bad boy up with s3d_set_callback(S3D_EVENT_KEY,key).

either way, the input-boxes get fed and your custom logic still gets to run. it's giving best of both worlds. 🌈


πŸ‘‘ AUTHOR πŸ‘‘

Simon Wunderlich β€” Author of s3d 🧚


that's the whole page, bestie, no filler, no notes πŸ’€βœ¨ and if you ever forget who wrote this iconic little library β€” it's Simon Wunderlich, and the whole thing lives under the s3d source, S3DW_HANDLE_KEY(3), section 3, library-call royalty. go forth and handle those keys, you've got this πŸ“πŸ’œπŸ’–