When inputting left click SDL_TextInputEvent.text is invalid so cant strlen. Any way to check before using it?
Is event type SDL_EVENT_TEXT_INPUT
? “Left click” sounds like a SDL_EVENT_MOUSE_BUTTON_DOWN
in which case you should only use the event button
member.
Oh you’re right my switch case was falling through from mouse button down event lol. Forgot the breaks and no warnings for some reason. Thx.
case SDL_EVENT_MOUSE_BUTTON_DOWN:
state->input.button_down_flags |= SDL_BUTTON_MASK(event.button.button);
case SDL_EVENT_MOUSE_BUTTON_UP:
if (event.button.down) {
break;
}
state->input.button_up_flags |= SDL_BUTTON_MASK(event.button.button);
case SDL_EVENT_TEXT_INPUT: {
u8 y = *event.text.text;
i32 x = strlen(event.text.text);
printf("%s\n", event.text.text);
}
1 Like