Skip to content

Commit

Permalink
fix simulated double click for left mouse button only
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmipt committed Feb 16, 2024
1 parent b40febb commit 0b78f08
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/studio/ui/QGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 0b78f08

Please sign in to comment.