Ctrl + click doesn't add components to the selection in MacOS

This commit is contained in:
Branislav Stojkovic
2018-12-25 23:40:05 +01:00
parent e9615d4d64
commit ce0ac2460c
7 changed files with 197 additions and 203 deletions
@@ -617,7 +617,7 @@ public class Presenter implements IPlugInPort {
IDIYComponent<?> topComponent = components.get(0); IDIYComponent<?> topComponent = components.get(0);
// If ctrl is pressed just toggle the component under mouse // If ctrl is pressed just toggle the component under mouse
// cursor. // cursor.
if (!Utils.isMac() && ctrlDown) { if (ctrlDown) {
if (newSelection.contains(topComponent)) { if (newSelection.contains(topComponent)) {
newSelection.removeAll(findAllGroupedComponents(topComponent)); newSelection.removeAll(findAllGroupedComponents(topComponent));
} else { } else {
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -47,7 +47,6 @@ import javax.swing.SwingUtilities;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.appframework.miscutils.IConfigListener; import org.diylc.appframework.miscutils.IConfigListener;
import org.diylc.appframework.miscutils.Utils;
import org.diylc.common.BadPositionException; import org.diylc.common.BadPositionException;
import org.diylc.common.EventType; import org.diylc.common.EventType;
import org.diylc.common.IComponentTransformer; import org.diylc.common.IComponentTransformer;
@@ -137,22 +136,30 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
canvasPanel = new CanvasPanel(plugInPort); canvasPanel = new CanvasPanel(plugInPort);
canvasPanel.addMouseListener(new MouseAdapter() { canvasPanel.addMouseListener(new MouseAdapter() {
private MouseEvent pressedEvent;
@Override
public void mouseClicked(MouseEvent e) {
plugInPort.mouseClicked(e.getPoint(), e.getButton(), e.isControlDown(), e.isShiftDown(), e.isAltDown(),
e.getClickCount());
}
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
LOG.info("Pressed: " + e.isPopupTrigger());
canvasPanel.requestFocus(); canvasPanel.requestFocus();
mouseReleased(e); pressedEvent = e;
} }
@Override @Override
public void mouseReleased(final MouseEvent e) { public void mouseReleased(final MouseEvent e) {
// Invoke the rest of the code later so we get the chance to // Invoke the rest of the code later so we get the chance to
// process selection messages. // process selection messages.
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
if (plugInPort.getNewComponentTypeSlot() == null && e.isPopupTrigger()) { if (plugInPort.getNewComponentTypeSlot() == null && (e.isPopupTrigger() || pressedEvent.isPopupTrigger())) {
// Enable actions. // Enable actions.
boolean enabled = !plugInPort.getSelectedComponents().isEmpty(); boolean enabled = !plugInPort.getSelectedComponents().isEmpty();
getCutAction().setEnabled(enabled); getCutAction().setEnabled(enabled);
@@ -192,8 +199,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
@Override @Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (plugInPort.keyPressed(e.getKeyCode(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(), if (plugInPort.keyPressed(e.getKeyCode(), e.isControlDown(), e.isShiftDown(), e.isAltDown())) {
e.isShiftDown(), e.isAltDown())) {
e.consume(); e.consume();
} }
} }
@@ -204,17 +210,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
@Override @Override
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
canvasPanel.setCursor(plugInPort.getCursorAt(e.getPoint())); canvasPanel.setCursor(plugInPort.getCursorAt(e.getPoint()));
plugInPort.mouseMoved(e.getPoint(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(), e.isShiftDown(), plugInPort.mouseMoved(e.getPoint(), e.isControlDown(), e.isShiftDown(), e.isAltDown());
e.isAltDown());
}
});
canvasPanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
plugInPort.mouseClicked(e.getPoint(), e.getButton(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(),
e.isShiftDown(), e.isAltDown(), e.getClickCount());
} }
}); });
} }
@@ -250,7 +246,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
boolean wheelZoom = ConfigurationManager.getInstance().readBoolean(IPlugInPort.WHEEL_ZOOM_KEY, false); boolean wheelZoom = ConfigurationManager.getInstance().readBoolean(IPlugInPort.WHEEL_ZOOM_KEY, false);
if (wheelZoom || (Utils.isMac() ? e.isMetaDown() : e.isControlDown())) { if (wheelZoom || e.isControlDown()) {
Point mousePos = getCanvasPanel().getMousePosition(true); Point mousePos = getCanvasPanel().getMousePosition(true);
@@ -1,23 +1,19 @@
/* /*
*
DIY Layout Creator (DIYLC). * DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
Copyright (c) 2009-2018 held jointly by the individual authors. *
* This file is part of DIYLC.
This file is part of DIYLC. *
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
DIYLC is free software: you can redistribute it and/or modify * General Public License as published by the Free Software Foundation, either version 3 of the
it under the terms of the GNU General Public License as published by * License, or (at your option) any later version.
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
DIYLC is distributed in the hope that it will be useful, * Public License for more details.
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * You should have received a copy of the GNU General Public License along with DIYLC. If not, see
GNU General Public License for more details. * <http://www.gnu.org/licenses/>.
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.toolbox; package org.diylc.swing.plugins.toolbox;
@@ -43,7 +39,6 @@ import javax.swing.SwingUtilities;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import org.diylc.appframework.miscutils.Utils;
import org.diylc.common.ComponentType; import org.diylc.common.ComponentType;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -90,7 +85,7 @@ public class ComponentButtonFactory {
} }
} }
// Ctrl appends selection // Ctrl appends selection
if (Utils.isMac() ? e.isMetaDown() : e.isControlDown()) { if (e.isControlDown()) {
newSelection.addAll(plugInPort.getSelectedComponents()); newSelection.addAll(plugInPort.getSelectedComponents());
} }
plugInPort.updateSelection(newSelection); plugInPort.updateSelection(newSelection);
@@ -104,8 +99,7 @@ public class ComponentButtonFactory {
@Override @Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
plugInPort.keyPressed(e.getKeyCode(), Utils.isMac() ? e.isMetaDown() : e.isControlDown(), e.isShiftDown(), plugInPort.keyPressed(e.getKeyCode(), e.isControlDown(), e.isShiftDown(), e.isAltDown());
e.isAltDown());
} }
}); });
return button; return button;
+5 -1
View File
@@ -2052,7 +2052,11 @@
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>Clicking on a building block twice in a row inside the component tree would make the components go back to the top-left corner of the layout</description> <description>Clicking on a building block in the component tree sometimes makes the components go back to the top-left corner of the layout</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Ctrl + click doesn't add components to the selection in MacOS</description>
</org.diylc.appframework.update.Change> </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>