From 0b78f0821c640dee822bc6573af7cd60d9092ca4 Mon Sep 17 00:00:00 2001 From: dzmipt Date: Fri, 16 Feb 2024 10:10:37 +0100 Subject: [PATCH] fix simulated double click for left mouse button only --- src/studio/ui/QGrid.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/studio/ui/QGrid.java b/src/studio/ui/QGrid.java index 8ab9efd8..15c2fa43 100755 --- a/src/studio/ui/QGrid.java +++ b/src/studio/ui/QGrid.java @@ -199,13 +199,15 @@ public void stateChanged(ChangeEvent ev) { public void mousePressed(MouseEvent e) { if (maybeShowPopup(e)) return; + if (! SwingUtilities.isLeftMouseButton(e)) return; + int row = table.rowAtPoint(e.getPoint()); int col = table.columnAtPoint(e.getPoint()); - if ((e.getModifiers() & InputEvent.ALT_MASK) == InputEvent.ALT_MASK ) copy(row, col); + if ((e.getModifiers() & InputEvent.ALT_MASK) == InputEvent.ALT_MASK ) doubleClick(row, col); else if (row == lastRow && col == lastCol && System.currentTimeMillis() - lastTimestamp < doubleClickTimeout) { - copy(row, col); + doubleClick(row, col); } else { lastRow = row; lastCol = col; @@ -228,11 +230,13 @@ private boolean maybeShowPopup(MouseEvent e) { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() != 2) return; - copy(lastRow, lastCol); + if (! SwingUtilities.isLeftMouseButton(e)) return; + + doubleClick(lastRow, lastCol); } - private void copy(int row, int col) { + private void doubleClick(int row, int col) { lastCol = lastRow = -1; lastTimestamp = -1; if (row == -1 || col == -1) return; @@ -242,7 +246,7 @@ private void copy(int row, int col) { int type = b.getType(); if ( (type >= -19 && type <= -1) || (type >= 101 && type <= 103 ) || - type == 10 ) { + type == 10 || type == 4) { //@TODO: we shouldn't duplicate the logic here. KFormatContext formatContextForCell = new KFormatContext(formatContext);