overlay renderer: set currentManagedOverlay also when clicking
Requiring the mouse to be moved first causes dead clicks when the mouse is pressed immediately after entering overlay management mode. Also since resetOverlayManagementMode() clears the managed overlay, after dragging an overlay it again requires the mouse to be moved to pick up a click on it if dragging again or trying to reset the overlay.
This commit is contained in:
@@ -344,6 +344,9 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
||||
final Point mousePoint = mouseEvent.getPoint();
|
||||
mousePosition.setLocation(mousePoint);
|
||||
|
||||
// See if we've clicked on an overlay
|
||||
currentManagedOverlay = findMangedOverlay(mousePoint);
|
||||
|
||||
if (currentManagedOverlay == null)
|
||||
{
|
||||
return mouseEvent;
|
||||
@@ -389,26 +392,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
||||
|
||||
if (!inOverlayResizingMode && !inOverlayDraggingMode)
|
||||
{
|
||||
currentManagedOverlay = null;
|
||||
|
||||
synchronized (overlayManager)
|
||||
{
|
||||
for (Overlay overlay : overlayManager.getOverlays())
|
||||
{
|
||||
if (overlay.getPosition() == OverlayPosition.DYNAMIC || overlay.getPosition() == OverlayPosition.TOOLTIP)
|
||||
{
|
||||
// never allow moving dynamic or tooltip overlays
|
||||
continue;
|
||||
}
|
||||
|
||||
final Rectangle bounds = overlay.getBounds();
|
||||
if (bounds.contains(mousePoint))
|
||||
{
|
||||
currentManagedOverlay = overlay;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
currentManagedOverlay = findMangedOverlay(mousePoint);
|
||||
}
|
||||
|
||||
if (currentManagedOverlay == null || !currentManagedOverlay.isResizable())
|
||||
@@ -455,6 +439,33 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|
||||
return mouseEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an overlay to manage which is under the given mouse point
|
||||
* @param mousePoint
|
||||
* @return
|
||||
*/
|
||||
private Overlay findMangedOverlay(Point mousePoint)
|
||||
{
|
||||
synchronized (overlayManager)
|
||||
{
|
||||
for (Overlay overlay : overlayManager.getOverlays())
|
||||
{
|
||||
if (overlay.getPosition() == OverlayPosition.DYNAMIC || overlay.getPosition() == OverlayPosition.TOOLTIP)
|
||||
{
|
||||
// never allow moving dynamic or tooltip overlays
|
||||
continue;
|
||||
}
|
||||
|
||||
final Rectangle bounds = overlay.getBounds();
|
||||
if (bounds.contains(mousePoint))
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MouseEvent mouseDragged(MouseEvent mouseEvent)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user