From ae38a6912b4b226829ce36043c4480f13efb7ef4 Mon Sep 17 00:00:00 2001 From: MrTheShy <49885496+MrTheShy@users.noreply.github.com> Date: Fri, 6 Mar 2026 05:50:09 +0100 Subject: [PATCH] Fix mouse hover hitting removed controls (ghost hitboxes) When removeControl() removes a Flash element (e.g. the Reinstall button in Help & Options, or the Debug button when disabled), the C++ control object stays in the m_controls vector. On Vita this was handled by calling setHidden(true) and checking getHidden() in the touch hit-test, but on Windows64 none of that was happening. The result: removed buttons kept phantom bounds that the hover code would match against, stealing focus from the buttons that shifted into their visual position. In the Help & Options menu with debug enabled, the removed Reinstall button (Button6) had ghost bounds overlapping where the Debug button (Button7) moved to after the removal, making Debug un-hoverable and snapping focus to Button1. The fix has three parts: - removeControl() now calls setHidden(true) on all platforms, not just Vita. The m_bHidden member was already declared on all platforms, only the accessors were ifdef'd behind __PSVITA__. - Removed the __PSVITA__ ifdef from setHidden/getHidden in UIControl.h so they're available everywhere. - Added getHidden() checks in both the hover and click hit-test loops, matching what the Vita touch code already does. The check is a simple bool read (no Flash/Iggy call), placed before the getVisible() query which hits Flash and can return stale values for removed elements. --- Minecraft.Client/Common/UI/UIControl.h | 2 -- Minecraft.Client/Common/UI/UIController.cpp | 2 +- Minecraft.Client/Common/UI/UIScene.cpp | 7 ++++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Minecraft.Client/Common/UI/UIControl.h b/Minecraft.Client/Common/UI/UIControl.h index 9062ce9ba..8445af0fc 100644 --- a/Minecraft.Client/Common/UI/UIControl.h +++ b/Minecraft.Client/Common/UI/UIControl.h @@ -64,10 +64,8 @@ public: virtual bool setupControl(UIScene *scene, IggyValuePath *parent, const string &controlName); void UpdateControl(); -#ifdef __PSVITA__ void setHidden(bool bHidden) {m_bHidden=bHidden;} bool getHidden(void) {return m_bHidden;} -#endif IggyValuePath *getIggyValuePath(); diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 1d69c6e10..f059d8211 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -865,7 +865,7 @@ void UIController::tickInput() for (size_t i = 0; i < controls->size(); ++i) { UIControl *ctrl = (*controls)[i]; - if (!ctrl || !ctrl->getVisible() || ctrl->getId() < 0) + if (!ctrl || ctrl->getHidden() || !ctrl->getVisible() || ctrl->getId() < 0) continue; UIControl::eUIControlType type = ctrl->getControlType(); diff --git a/Minecraft.Client/Common/UI/UIScene.cpp b/Minecraft.Client/Common/UI/UIScene.cpp index dc5c9d8fc..0aedbf18f 100644 --- a/Minecraft.Client/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Common/UI/UIScene.cpp @@ -478,7 +478,7 @@ bool UIScene::handleMouseClick(F32 x, F32 y) for (size_t i = 0; i < controls->size(); ++i) { UIControl *ctrl = (*controls)[i]; - if (!ctrl || !ctrl->getVisible() || ctrl->getId() < 0) + if (!ctrl || ctrl->getHidden() || !ctrl->getVisible() || ctrl->getId() < 0) continue; UIControl::eUIControlType type = ctrl->getControlType(); @@ -607,12 +607,13 @@ void UIScene::removeControl( UIControl_Base *control, bool centreScene) // update the button positions since they may have changed UpdateSceneControls(); - // mark the button as removed - control->setHidden(true); // remove it from the touchboxes ui.TouchBoxRebuild(control->getParentScene()); #endif + // mark the button as removed so hover/touch hit-tests skip it + control->setHidden(true); + } void UIScene::slideLeft()