Merge pull request #3000 from swazrgb/overlay-focusable
client: Make overlays aware of mouse focus
This commit is contained in:
@@ -97,6 +97,14 @@ public abstract class Overlay implements LayoutableRenderableEntity
|
||||
{
|
||||
}
|
||||
|
||||
public void onMouseEnter()
|
||||
{
|
||||
}
|
||||
|
||||
public void onMouseExit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an overlay is dragged onto this, if dragTargetable is true.
|
||||
* Return true to consume the mouse event and prevent the other
|
||||
|
||||
@@ -107,6 +107,10 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
||||
private boolean isResizeable;
|
||||
private OverlayBounds emptySnapCorners, snapCorners;
|
||||
|
||||
// focused overlay
|
||||
private Overlay focusedOverlay;
|
||||
private Overlay prevFocusedOverlay;
|
||||
|
||||
@Inject
|
||||
private OverlayRenderer(
|
||||
final Client client,
|
||||
@@ -174,6 +178,14 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
||||
{
|
||||
menuEntries = null;
|
||||
|
||||
if (focusedOverlay == null && prevFocusedOverlay != null)
|
||||
{
|
||||
prevFocusedOverlay.onMouseExit();
|
||||
}
|
||||
|
||||
prevFocusedOverlay = focusedOverlay;
|
||||
focusedOverlay = null;
|
||||
|
||||
if (client.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
|
||||
@@ -352,6 +364,20 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
||||
menuEntries = createRightClickMenuEntries(overlay);
|
||||
}
|
||||
|
||||
if (focusedOverlay == null)
|
||||
{
|
||||
focusedOverlay = overlay;
|
||||
if (focusedOverlay != prevFocusedOverlay)
|
||||
{
|
||||
if (prevFocusedOverlay != null)
|
||||
{
|
||||
prevFocusedOverlay.onMouseExit();
|
||||
}
|
||||
|
||||
overlay.onMouseEnter();
|
||||
}
|
||||
}
|
||||
|
||||
overlay.onMouseOver();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user