check x/y coord

This commit is contained in:
NishiOwO 2025-04-20 17:28:40 +09:00
parent 779ddc4251
commit 47353ce63b
No known key found for this signature in database
GPG Key ID: 27EF69B208EB9343
2 changed files with 3 additions and 3 deletions

View File

@ -101,7 +101,7 @@ void gf_gui_render(gf_gui_t* gui) {
double ch = c->height;
switch(c->type) {
case GF_GUI_BUTTON: {
if((gui->pressed == -1) && (input->mouse_flag & GF_INPUT_MOUSE_LEFT_MASK) && (cx <= input->mouse_x && input->mouse_x <= cx + cw) && (cy <= input->mouse_y && input->mouse_y <= cy + ch)) {
if(input->mouse_x != -1 && input->mouse_y != -1 && gui->pressed == -1 && (input->mouse_flag & GF_INPUT_MOUSE_LEFT_MASK) && (cx <= input->mouse_x && input->mouse_x <= cx + cw) && (cy <= input->mouse_y && input->mouse_y <= cy + ch)) {
gui->pressed = i;
} else if(gui->pressed == -1) {
c->pressed = 0;

View File

@ -19,8 +19,8 @@ gf_input_t* gf_input_create(gf_engine_t* engine) {
memset(input, 0, sizeof(input));
input->engine = engine;
input->mouse_x = 0;
input->mouse_y = 0;
input->mouse_x = -1;
input->mouse_y = -1;
input->mouse_flag = 0;
return input;