diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/HotbarView.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/HotbarView.java index 522b0fe5b..b969fc83a 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/HotbarView.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/mouse/HotbarView.java @@ -11,6 +11,7 @@ import android.view.ViewParent; import androidx.annotation.Nullable; +import net.kdt.pojavlaunch.GrabListener; import net.kdt.pojavlaunch.LwjglGlfwKeycode; import net.kdt.pojavlaunch.prefs.LauncherPreferences; import net.kdt.pojavlaunch.utils.MCOptionUtils; @@ -26,8 +27,16 @@ public class HotbarView extends View implements MCOptionUtils.MCOptionListener, LwjglGlfwKeycode.GLFW_KEY_4, LwjglGlfwKeycode.GLFW_KEY_5, LwjglGlfwKeycode.GLFW_KEY_6, LwjglGlfwKeycode.GLFW_KEY_7, LwjglGlfwKeycode.GLFW_KEY_8, LwjglGlfwKeycode.GLFW_KEY_9}; private final DropGesture mDropGesture = new DropGesture(new Handler(Looper.getMainLooper())); + private final GrabListener mGrabListener = new GrabListener() { + @Override + public void onGrabState(boolean isGrabbing) { + mLastIndex = -1; + mDropGesture.cancel(); + } + }; + private int mWidth; - private int mLastIndex; + private int mLastIndex = -1; private int mGuiScale; public HotbarView(Context context) { @@ -66,6 +75,13 @@ public class HotbarView extends View implements MCOptionUtils.MCOptionListener, } mGuiScale = MCOptionUtils.getMcScale(); repositionView(); + CallbackBridge.addGrabListener(mGrabListener); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + CallbackBridge.removeGrabListener(mGrabListener); } private void repositionView() {