diff --git a/src/pc/djui/djui_base.c b/src/pc/djui/djui_base.c index 7b60017e5..46e81d405 100644 --- a/src/pc/djui/djui_base.c +++ b/src/pc/djui/djui_base.c @@ -353,6 +353,11 @@ void djui_base_destroy(struct DjuiBase* base) { gInteractableBinding = NULL; } + // remove input controlled base + if (gInputControlledBase == base) { + gInputControlledBase = NULL; + } + // remove myself from parent's linked list if (base->parent != NULL) { struct DjuiBaseChild* child = base->parent->child; diff --git a/src/pc/djui/djui_cursor.c b/src/pc/djui/djui_cursor.c index 7c336a74f..4c7dfde7f 100644 --- a/src/pc/djui/djui_cursor.c +++ b/src/pc/djui/djui_cursor.c @@ -12,7 +12,7 @@ extern ALIGNED8 u8 gd_texture_hand_closed[]; struct DjuiImage* sMouseCursor = NULL; static bool sCursorMouseControlled = false; -static struct DjuiBase* sInputControlledBase = NULL; +struct DjuiBase* gInputControlledBase = NULL; static f32 sSavedMouseX = 0; static f32 sSavedMouseY = 0; @@ -55,7 +55,7 @@ static void djui_cursor_base_hover_location(struct DjuiBase* base, f32* x, f32* void djui_cursor_input_controlled_center(struct DjuiBase* base) { if (!sCursorMouseControlled && (!base || (base && base->interactable && base->interactable->enabled))) { - sInputControlledBase = base; + gInputControlledBase = base; djui_cursor_set_visible(base != NULL); } } @@ -147,8 +147,8 @@ static void djui_cursor_update_position(void) { if (sCursorMouseControlled) { gCursorX = mouse_window_x / djui_gfx_get_scale(); gCursorY = mouse_window_y / djui_gfx_get_scale(); - } else if (sInputControlledBase != NULL) { - djui_cursor_base_hover_location(sInputControlledBase, &gCursorX, &gCursorY); + } else if (gInputControlledBase != NULL) { + djui_cursor_base_hover_location(gInputControlledBase, &gCursorX, &gCursorY); } // set cursor position diff --git a/src/pc/djui/djui_cursor.h b/src/pc/djui/djui_cursor.h index bc9374060..e485ba4b2 100644 --- a/src/pc/djui/djui_cursor.h +++ b/src/pc/djui/djui_cursor.h @@ -5,6 +5,8 @@ extern f32 gCursorX; extern f32 gCursorY; +extern struct DjuiBase* gInputControlledBase; + void djui_cursor_set_visible(bool visible); bool djui_cursor_inside_base(struct DjuiBase* base); void djui_cursor_input_controlled_center(struct DjuiBase* base);