diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkColorTableCellRendererEditor.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkColorTableCellRendererEditor.java index 39e9b93f..d7e94f56 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkColorTableCellRendererEditor.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkColorTableCellRendererEditor.java @@ -77,7 +77,7 @@ public class DarkColorTableCellRendererEditor extends AbstractCellEditor impleme if (anEvent instanceof MouseEvent) { return ((MouseEvent) anEvent).getClickCount() >= 2; } - return true; + return false; } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java index 1b422d01..24e6c75b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java @@ -34,6 +34,7 @@ import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; import javax.swing.table.TableCellEditor; import java.awt.*; +import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.text.DateFormat; import java.text.NumberFormat; @@ -177,6 +178,9 @@ public class DarkTableCellEditor extends DefaultCellEditor { @Override public boolean isCellEditable(final EventObject anEvent) { if (anEvent == null) return super.isCellEditable(anEvent); + if (anEvent instanceof KeyEvent) { + if (DarkTableUI.ignoreKeyCodeOnEdit((KeyEvent) anEvent)) return false; + } JTable table = ((JTable) anEvent.getSource()); if (DarkTableCellRenderer.isBooleanRenderingEnabled(table) && anEvent instanceof MouseEvent) { Point p = ((MouseEvent) anEvent).getPoint(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java index afd40c7a..3a55289d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java @@ -36,10 +36,7 @@ import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.MouseEvent; +import java.awt.event.*; import java.beans.PropertyChangeListener; import java.util.function.Supplier; @@ -420,6 +417,23 @@ public class DarkTableUI extends DarkTableUIBridge { } } + public static boolean ignoreKeyCodeOnEdit(final KeyEvent event) { + if (event != null) { + int keyCode = event.getKeyCode(); + switch (keyCode) { + case KeyEvent.VK_ALT_GRAPH: + case KeyEvent.VK_META: + case KeyEvent.VK_CAPS_LOCK: + case KeyEvent.VK_HOME: + case KeyEvent.VK_WINDOWS: + return true; + default: + break; + } + } + return false; + } + protected class DarkHandler extends Handler { protected int lastIndex = -1; @@ -481,6 +495,12 @@ public class DarkTableUI extends DarkTableUIBridge { @Override public void actionPerformed(final ActionEvent ae) { } + + @Override + public void keyTyped(final KeyEvent e) { + if (ignoreKeyCodeOnEdit(e)) return; + super.keyTyped(e); + } } protected boolean isFocusCell(final int row, final int col) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java index c4ec5177..73bcbb47 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java @@ -2217,8 +2217,7 @@ public abstract class TableUIBridge extends TableUI { if (map != null && map.get(keyStroke) != null) { return; } - map = table.getInputMap(JComponent. - WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + map = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); if (map != null && map.get(keyStroke) != null) { return; }