From e9573c9fb06d64d996ab6666f65e6a0649992ebc Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 16 Aug 2024 16:00:33 -0400 Subject: [PATCH] Added Scene#getHoverElement --- arc-core/src/arc/scene/Scene.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arc-core/src/arc/scene/Scene.java b/arc-core/src/arc/scene/Scene.java index f63613c0..8b61610d 100644 --- a/arc-core/src/arc/scene/Scene.java +++ b/arc-core/src/arc/scene/Scene.java @@ -93,12 +93,16 @@ public void registerStyles(Object obj){ .each(f -> f.getName().startsWith("default"), f -> addStyle(f.getType(), Reflect.get(obj, f))); } + public @Nullable Element getHoverElement(){ + return mouseOverElement; + } + public boolean hasField(){ return getKeyboardFocus() instanceof TextField; } public boolean hasMouse(){ - return hit(Core.input.mouseX(), Core.input.mouseY(), true) != null; + return mouseOverElement != null; } public boolean hasMouse(float mousex, float mousey){ @@ -178,8 +182,11 @@ public void act(float delta){ pointerOverActors[pointer] = fireEnterAndExit(overLast, pointerScreenX[pointer], pointerScreenY[pointer], pointer); } // Update over element for the mouse on the desktop. - if(Core.app.isDesktop() || Core.app.isWeb()) + if(Core.app.isDesktop() || Core.app.isWeb()){ mouseOverElement = fireEnterAndExit(mouseOverElement, mouseScreenX, mouseScreenY, -1); + }else{ + mouseOverElement = hit(mouseScreenX, mouseScreenY, true); + } if(scrollFocus != null && (!scrollFocus.visible || scrollFocus.getScene() == null)) scrollFocus = null; if(keyboardFocus != null && (!keyboardFocus.visible || keyboardFocus.getScene() == null)) keyboardFocus = null;