mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Dragging components from the component tree to the canvas stops working
once the component type is selected in the tree
This commit is contained in:
@@ -1649,7 +1649,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
if (selectedComponents.isEmpty()) {
|
if (selectedComponents.isEmpty()) {
|
||||||
// If there's no selection finalize selectionRect and see which
|
// If there's no selection finalize selectionRect and see which
|
||||||
// components intersect with it.
|
// components intersect with it.
|
||||||
if (scaledPoint != null) {
|
if (scaledPoint != null && previousDragPoint != null) {
|
||||||
this.selectionRect = Utils.createRectangle(new Point((int)scaledPoint.getX(), (int)scaledPoint.getY()),
|
this.selectionRect = Utils.createRectangle(new Point((int)scaledPoint.getX(), (int)scaledPoint.getY()),
|
||||||
new Point((int)previousDragPoint.getX(), (int)previousDragPoint.getY()));;
|
new Point((int)previousDragPoint.getX(), (int)previousDragPoint.getY()));;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3326,6 +3326,10 @@
|
|||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>When rotating Vero and Tri-Pad boards, change the orientation of strips to match the rotation angle</description>
|
<description>When rotating Vero and Tri-Pad boards, change the orientation of strips to match the rotation angle</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>BUG_FIX</changeType>
|
||||||
|
<description>Dragging components from the component tree to the canvas stops working once the component type is selected in the tree</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
</org.diylc.appframework.update.Version>
|
</org.diylc.appframework.update.Version>
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ package org.diylc.swing.plugins.tree;
|
|||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.dnd.DragGestureEvent;
|
import java.awt.dnd.DragGestureEvent;
|
||||||
import java.awt.dnd.DragGestureListener;
|
import java.awt.dnd.DragGestureListener;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
|
|
||||||
import org.diylc.common.ComponentType;
|
import org.diylc.common.ComponentType;
|
||||||
@@ -46,16 +46,15 @@ class TreeGestureListener implements DragGestureListener {
|
|||||||
@Override
|
@Override
|
||||||
public void dragGestureRecognized(DragGestureEvent dge) {
|
public void dragGestureRecognized(DragGestureEvent dge) {
|
||||||
ComponentType type = null;
|
ComponentType type = null;
|
||||||
TreeNode payload = null;
|
MouseListener clickListener = null;
|
||||||
if (presenter.getNewComponentTypeSlot() == null) {
|
if (presenter.getNewComponentTypeSlot() == null) {
|
||||||
JTree tree = (JTree) dge.getComponent();
|
JTree tree = (JTree) dge.getComponent();
|
||||||
Point p = dge.getDragOrigin();
|
Point p = dge.getDragOrigin();
|
||||||
TreePath path = tree.getClosestPathForLocation(p.x, p.y);
|
TreePath path = tree.getClosestPathForLocation(p.x, p.y);
|
||||||
if (path != null && path.getLastPathComponent() instanceof DefaultMutableTreeNode) {
|
if (path != null && path.getLastPathComponent() instanceof TreeNode) {
|
||||||
DefaultMutableTreeNode leaf = (DefaultMutableTreeNode) path.getLastPathComponent();
|
TreeNode leaf = (TreeNode) path.getLastPathComponent();
|
||||||
payload = (TreeNode) leaf.getUserObject();
|
clickListener = leaf.getClickListener();
|
||||||
if (payload != null && (payload.getComponentType() != null || payload.getClickListener() != null))
|
type = leaf.getComponentType();
|
||||||
type = payload.getComponentType();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
type = presenter.getNewComponentTypeSlot();
|
type = presenter.getNewComponentTypeSlot();
|
||||||
@@ -64,8 +63,8 @@ class TreeGestureListener implements DragGestureListener {
|
|||||||
boolean start = false;
|
boolean start = false;
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
if (payload != null && payload.getClickListener() != null) {
|
if (clickListener != null) {
|
||||||
payload.getClickListener().mouseClicked(null);
|
clickListener.mouseClicked(null);
|
||||||
start = true;
|
start = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user