diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index ea46b25feb0..28204b87a42 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -132,6 +132,7 @@ import org.jabref.logic.undo.AddUndoableActionEvent; import org.jabref.logic.undo.UndoChangeEvent; import org.jabref.logic.undo.UndoRedoEvent; +import org.jabref.logic.util.OS; import org.jabref.logic.util.io.FileUtil; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.shared.DatabaseLocation; @@ -278,6 +279,11 @@ private void initKeyBindings() { case NEW_UNPUBLISHED: new NewEntryAction(this, StandardEntryType.Unpublished, dialogService, prefs, stateManager).execute(); break; + case PASTE: + if (OS.OS_X) { // Workaround for a jdk issue that executes paste twice when using cmd+v in a TextField + event.consume(); + break; + } default: } } diff --git a/src/main/java/org/jabref/gui/actions/ActionFactory.java b/src/main/java/org/jabref/gui/actions/ActionFactory.java index 9174d96ff82..151a596b66c 100644 --- a/src/main/java/org/jabref/gui/actions/ActionFactory.java +++ b/src/main/java/org/jabref/gui/actions/ActionFactory.java @@ -136,6 +136,7 @@ public Button createIconButton(Action action, Command command) { button.graphicProperty().unbind(); action.getIcon().ifPresent(icon -> button.setGraphic(icon.getGraphicNode())); + button.setFocusTraversable(false); // Prevent the buttons from stealing the focus return button; } diff --git a/src/main/java/org/jabref/gui/edit/EditAction.java b/src/main/java/org/jabref/gui/edit/EditAction.java index 2835d825c70..a05b592b190 100644 --- a/src/main/java/org/jabref/gui/edit/EditAction.java +++ b/src/main/java/org/jabref/gui/edit/EditAction.java @@ -40,6 +40,7 @@ public String toString() { @Override public void execute() { stateManager.getFocusOwner().ifPresent(focusOwner -> { + LOGGER.debug("EditAction - focusOwner: {}; Action: {}", focusOwner.toString(), action.getText()); if (focusOwner instanceof TextInputControl) { // Focus is on text field -> copy/paste/cut selected text TextInputControl textInput = (TextInputControl) focusOwner; @@ -63,7 +64,7 @@ public void execute() { } else if (focusOwner instanceof MainTable) { - LOGGER.debug("I am a Maintable in Edit action"); + LOGGER.debug("EditAction - MainTable: {}", frame.getCurrentBasePanel().getTabTitle()); // Not sure what is selected -> copy/paste/cut selected entries // ToDo: Should be handled by BibDatabaseContext instead of BasePanel diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index 67f2427912d..e646b56b286 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -29,6 +29,8 @@ import org.jabref.gui.DialogService; import org.jabref.gui.DragAndDropDataFormats; import org.jabref.gui.StateManager; +import org.jabref.gui.actions.StandardActions; +import org.jabref.gui.edit.EditAction; import org.jabref.gui.externalfiles.ImportHandler; import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.keyboard.KeyBinding; @@ -237,17 +239,17 @@ private void setupKeyBindings(KeyBindingRepository keyBindings) { event.consume(); break; case PASTE: - if (!OS.OS_X) { // ugly hack, prevents duplicate entries on pasting. Side effect: Prevents pasting using cmd+v on an empty library - paste(); - event.consume(); - break; + if (!OS.OS_X) { + new EditAction(StandardActions.PASTE, panel.frame(), Globals.stateManager).execute(); } + event.consume(); + break; case COPY: - copy(); + new EditAction(StandardActions.COPY, panel.frame(), Globals.stateManager).execute(); event.consume(); break; case CUT: - cut(); + new EditAction(StandardActions.CUT, panel.frame(), Globals.stateManager).execute(); event.consume(); break; default: