mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
Bug/mac click issue (#879)
* attempt to fix bug * fix * update * update
This commit is contained in:
@@ -4494,6 +4494,10 @@
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Loading files that contain lines with end arrows sometimes produces errors in the log and lines not to be loaded</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Mouse click to select intermittently doesn't register on Mac machines</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+29
-26
@@ -1,30 +1,30 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.swing.plugins.canvas;
|
||||
|
||||
import java.awt.dnd.DragGestureEvent;
|
||||
import java.awt.dnd.DragGestureListener;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.dnd.DragGestureEvent;
|
||||
import java.awt.dnd.DragGestureListener;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
|
||||
/**
|
||||
@@ -35,10 +35,12 @@ import org.diylc.common.IPlugInPort;
|
||||
class CanvasDragGestureListener implements DragGestureListener {
|
||||
|
||||
private IPlugInPort presenter;
|
||||
private CanvasPanel canvasPanel;
|
||||
|
||||
public CanvasDragGestureListener(IPlugInPort presenter) {
|
||||
public CanvasDragGestureListener(IPlugInPort presenter, CanvasPanel canvasPanel) {
|
||||
super();
|
||||
this.presenter = presenter;
|
||||
this.canvasPanel = canvasPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,6 +51,7 @@ class CanvasDragGestureListener implements DragGestureListener {
|
||||
MouseEvent me = (MouseEvent) e;
|
||||
forceReSelection = me.getButton() != MouseEvent.BUTTON1;
|
||||
}
|
||||
canvasPanel.setClickInProgress(false);
|
||||
presenter.dragStarted(dge.getDragOrigin(), dge.getDragAction(), forceReSelection);
|
||||
dge.startDrag(presenter.getCursorAt(dge.getDragOrigin(), false, false, false), new EmptyTransferable(), new CanvasSourceListener(
|
||||
presenter));
|
||||
|
||||
@@ -84,6 +84,8 @@ public class CanvasPanel extends JComponent implements Autoscroll {
|
||||
private HashMap<String, ComponentType> componentTypeCache;
|
||||
|
||||
private IConfigurationManager<?> configManager;
|
||||
|
||||
private boolean clickInProgress = false;
|
||||
|
||||
public CanvasPanel(IPlugInPort plugInPort, IConfigurationManager<?> configManager) {
|
||||
this.plugInPort = plugInPort;
|
||||
@@ -116,12 +118,20 @@ public class CanvasPanel extends JComponent implements Autoscroll {
|
||||
}
|
||||
return componentTypeCache;
|
||||
}
|
||||
|
||||
public void setClickInProgress(boolean clickInProgress) {
|
||||
this.clickInProgress = clickInProgress;
|
||||
}
|
||||
|
||||
public boolean isClickInProgress() {
|
||||
return clickInProgress;
|
||||
}
|
||||
|
||||
private void initializeDnD() {
|
||||
// Initialize drag source recognizer.
|
||||
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(this,
|
||||
DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK,
|
||||
new CanvasDragGestureListener(plugInPort));
|
||||
new CanvasDragGestureListener(plugInPort, this));
|
||||
// Initialize drop target.
|
||||
new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, new CanvasTargetListener(plugInPort),
|
||||
true);
|
||||
|
||||
@@ -207,6 +207,8 @@ public class CanvasPlugin implements IPlugIn{
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
canvasPanel.setClickInProgress(false);
|
||||
|
||||
if (scrollPane.isMouseScrollMode() || e.getButton() == MouseEvent.BUTTON2)
|
||||
return;
|
||||
|
||||
@@ -220,6 +222,7 @@ public class CanvasPlugin implements IPlugIn{
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
canvasPanel.requestFocus();
|
||||
canvasPanel.setClickInProgress(true);
|
||||
pressedEvent = e;
|
||||
}
|
||||
|
||||
@@ -238,6 +241,14 @@ public class CanvasPlugin implements IPlugIn{
|
||||
int y = e.getY();
|
||||
getPopupMenu().prepareAndShowAt(plugInPort.findComponentsAt(new Point(x, y), false),
|
||||
plugInPort.findComponentsAt(new Point(x, y), true), x, y);
|
||||
} else if (canvasPanel.isClickInProgress()) {
|
||||
// ensure that the click is not lost in case mouseClicked was not triggered
|
||||
// and no drag action is performed
|
||||
canvasPanel.setClickInProgress(false);
|
||||
// do not pass isMetaDown on mac when button3 (two finger click) is pressed
|
||||
boolean ctrlDown = Utils.isMac() ? (e.getButton() == MouseEvent.BUTTON3 ? false : e.isMetaDown()): e.isControlDown();
|
||||
plugInPort.mouseClicked(e.getPoint(), e.getButton(),
|
||||
ctrlDown, e.isShiftDown(), e.isAltDown(), e.getClickCount());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user