Fix bug where you sometimes couldn't type to change player name

This commit is contained in:
MysterD 2023-04-18 12:40:51 -07:00
parent 79d2fd0ad3
commit d81f44534c
3 changed files with 6 additions and 3 deletions

View File

@ -292,13 +292,13 @@ void djui_inputbox_on_key_up(UNUSED struct DjuiBase *base, int scancode) {
}
}
static void djui_inputbox_on_focus_begin(UNUSED struct DjuiBase* base) {
void djui_inputbox_on_focus_begin(UNUSED struct DjuiBase* base) {
sHeldControl = 0;
sHeldShift = 0;
wm_api->start_text_input();
}
static void djui_inputbox_on_focus_end(UNUSED struct DjuiBase* base) {
void djui_inputbox_on_focus_end(UNUSED struct DjuiBase* base) {
wm_api->stop_text_input();
}

View File

@ -13,6 +13,8 @@ struct DjuiInputbox {
void (*on_escape_press)(struct DjuiInputbox*);
};
void djui_inputbox_on_focus_begin(UNUSED struct DjuiBase* base);
void djui_inputbox_on_focus_end(UNUSED struct DjuiBase* base);
void djui_inputbox_set_text_color(struct DjuiInputbox* inputbox, u8 r, u8 g, u8 b, u8 a);
void djui_inputbox_set_text(struct DjuiInputbox* inputbox, char* text);
void djui_inputbox_select_all(struct DjuiInputbox* inputbox);

View File

@ -196,6 +196,7 @@ static void djui_panel_player_name_on_focus_end(struct DjuiBase* caller) {
if (gNetworkType != NT_NONE) {
network_send_player_settings();
}
djui_inputbox_on_focus_end(&inputbox1->base);
}
static void djui_panel_player_value_changed(UNUSED struct DjuiBase* caller) {
@ -255,7 +256,7 @@ void djui_panel_player_create(struct DjuiBase* caller) {
djui_inputbox_set_text(inputbox1, DLANG(PLAYER, PLAYER));
}
djui_interactable_hook_value_change(&inputbox1->base, djui_panel_player_name_text_change);
djui_interactable_hook_focus(&inputbox1->base, NULL, NULL, djui_panel_player_name_on_focus_end);
djui_interactable_hook_focus(&inputbox1->base, djui_inputbox_on_focus_begin, NULL, djui_panel_player_name_on_focus_end);
}
char* modelChoices[CT_MAX] = { 0 };