pedromelocf / 42_fdf

All programs that you wrote until now were executed in text mode on your terminal. Now, let’s discover something more exciting: how to open a graphics window and draw inside? To start your journey in graphic programming, FdF offers to represent “iron wire” meshing in 3D.
2 stars 0 forks source link

Create hooks (esc, quit, ) #9

Closed pedromelocf closed 10 months ago

pedromelocf commented 10 months ago

Created function:

void key_hook(mlx_key_data_t keydata, void* param) { if (keydata.key == MLX_KEY_ESCAPE && keydata.action == MLX_PRESS && param == NULL) puts("Testing"); }

Still not beeing able to close at escape press but already printing "Testing" in the stdout.

Need another solution.

pedromelocf commented 10 months ago

mlx_key_hook(mlx, &key_hook, mlx);

void    key_hook(mlx_key_data_t keydata, void* mlx)
{
    if (keydata.key == MLX_KEY_ESCAPE && keydata.action == MLX_PRESS)
        mlx_close_window(mlx);
}