-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pressing "tab" when last textField of entry editor Tab is in focus will move to the next Tab. #12087
base: main
Are you sure you want to change the base?
Pressing "tab" when last textField of entry editor Tab is in focus will move to the next Tab. #12087
Changes from all commits
0047c50
c94c433
e98bd27
c80ed8c
334c467
04b0f0b
0afd9ce
1ee9a0e
2a167bd
2842f72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import javafx.scene.control.MenuItem; | ||
import javafx.scene.control.Tab; | ||
import javafx.scene.control.TabPane; | ||
import javafx.scene.control.TextField; | ||
import javafx.scene.input.DataFormat; | ||
import javafx.scene.input.KeyEvent; | ||
import javafx.scene.input.TransferMode; | ||
|
@@ -36,6 +37,7 @@ | |
import org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTab; | ||
import org.jabref.gui.entryeditor.fileannotationtab.FulltextSearchResultsTab; | ||
import org.jabref.gui.externalfiles.ExternalFilesEntryLinker; | ||
import org.jabref.gui.fieldeditors.EditorTextField; | ||
import org.jabref.gui.help.HelpAction; | ||
import org.jabref.gui.importer.GrobidOptInDialogHelper; | ||
import org.jabref.gui.keyboard.KeyBinding; | ||
|
@@ -142,6 +144,7 @@ public EntryEditor(LibraryTab libraryTab, UndoAction undoAction, RedoAction redo | |
this.previewTabs = this.allPossibleTabs.stream().filter(OffersPreview.class::isInstance).map(OffersPreview.class::cast).toList(); | ||
|
||
setupDragAndDrop(libraryTab); | ||
EditorTextField.entryContext(tabbed); | ||
|
||
EasyBind.subscribe(tabbed.getSelectionModel().selectedItemProperty(), tab -> { | ||
EntryEditorTab activeTab = (EntryEditorTab) tab; | ||
|
@@ -472,4 +475,20 @@ public void nextPreviewStyle() { | |
public void previousPreviewStyle() { | ||
this.previewTabs.forEach(OffersPreview::previousPreviewStyle); | ||
} | ||
|
||
public static boolean checkLastTextField(TabPane tabs, TextField textField) { | ||
FieldsEditorTab currentTab = (FieldsEditorTab) tabs.getSelectionModel().getSelectedItem(); | ||
Collection<Field> shownFields = currentTab.getShownFields(); | ||
Field lastField = null; | ||
for (Field field : shownFields) { | ||
lastField = field; | ||
} | ||
if (textField != null && lastField != null) { | ||
if (textField.getId() == null) { | ||
Comment on lines
+482
to
+487
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pease use Optionals in place of nulls. |
||
return false; | ||
} | ||
return lastField.getDisplayName().equalsIgnoreCase(textField.getId()); | ||
} | ||
return false; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,23 +9,34 @@ | |
import javafx.fxml.Initializable; | ||
import javafx.scene.control.ContextMenu; | ||
import javafx.scene.control.MenuItem; | ||
import javafx.scene.control.TabPane; | ||
import javafx.scene.control.TextField; | ||
import javafx.scene.input.KeyEvent; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.Priority; | ||
|
||
import org.jabref.gui.ClipBoardManager; | ||
import org.jabref.gui.entryeditor.EntryEditor; | ||
import org.jabref.gui.fieldeditors.contextmenu.EditorContextAction; | ||
import org.jabref.gui.keyboard.KeyBindingRepository; | ||
|
||
public class EditorTextField extends TextField implements Initializable, ContextMenuAddable { | ||
|
||
public static TabPane tabs; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make it non-static. |
||
private final ContextMenu contextMenu = new ContextMenu(); | ||
private Runnable additionalPasteActionHandler = () -> { | ||
// No additional paste behavior | ||
}; | ||
|
||
public EditorTextField() { | ||
this(""); | ||
this.addEventFilter(KeyEvent.KEY_PRESSED, event -> { | ||
String keyText = event.getText(); | ||
if ("\t".equals(keyText) && EntryEditor.checkLastTextField(tabs, this)) { | ||
tabs.getSelectionModel().selectNext(); | ||
event.consume(); | ||
} | ||
}); | ||
} | ||
|
||
public EditorTextField(final String text) { | ||
|
@@ -38,6 +49,10 @@ public EditorTextField(final String text) { | |
ClipBoardManager.addX11Support(this); | ||
} | ||
|
||
public static void entryContext(TabPane tab) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-static. |
||
tabs = tab; | ||
} | ||
|
||
@Override | ||
public void initContextMenu(final Supplier<List<MenuItem>> items, KeyBindingRepository keyBindingRepository) { | ||
setOnContextMenuRequested(event -> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this non-static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey,
Sorry, I'm not sure how. I believe I can make checkLastTextField non-static and use the tabbed TabPane in the EntryEditor instead. But in doing this, I would need to create a new instance of EntryEditor in EditorTextField which will require the following arguments: EntryEditor(LibraryTab libraryTab, UndoAction undoAction, RedoAction redoAction). -> which I'm not sure how to get from EditorTextField.
Please guide me how I could do this.
Thankyou!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you need a new instance of an entry editor? We only have one.
How about
this
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If im calling the non-static method
checkLastTextField
that's inEntryEditor
, that usesprivate TabPane tabbed
fromEditorTextField
. It requires me to create a new instance ofEntryEditor
inEditorTextField
. I believeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you create a new instance of an EntryEditor your changes would not affect the one we are displaying. There is only one EntryEditor. You probably have to inject a reference to the object you need.
But I believe there is a more serious architectural flaw, if you are trying to get a reference to to the big container node.
Why would you need the entry editor? Why would you need the TabbedPane? And what exactly do you need from the TabbedPane?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can 'inject' a method
selectNextTab
or sthg as a functional interface if really necessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need the TabPane to get the last Field of a tab and to select the next Tab