-
-
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?
Conversation
…ed fields" because the "CitationKey" isnt created in SimpleEditor.java and therefore hasn't had its textfield id updated.
…ed fields" because the "CitationKey" isnt created in SimpleEditor.java and therefore hasn't had its textfield id updated.
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.
Few requests on code quality.
Field lastField = null; | ||
for (Field field : shownFields) { | ||
lastField = field; | ||
} | ||
if (textField != null && lastField != null) { | ||
if (textField.getId() == null) { |
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.
Pease use Optionals in place of nulls.
@@ -472,4 +475,20 @@ public void nextPreviewStyle() { | |||
public void previousPreviewStyle() { | |||
this.previewTabs.forEach(OffersPreview::previousPreviewStyle); | |||
} | |||
|
|||
public static boolean checkLastTextField(TabPane tabs, TextField textField) { |
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.
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 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
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it non-static.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Non-static.
For reviewers - technical discussions were done at #11937 (comment), too. |
@Noah-Martin1 hey, sorry that the PR got a little stale. Were you able to figure out a way to conform to the remaining review comments? Did you try injecting the methods you needed using functional interfaces as suggested by @calixtus ? |
Hi sorry I have been on break since, and haven’t had a chance to look at it. I will look into the suggestions in a couple weeks. Thankyou |
Pressing "tab" when the last TextField of the entry editor Tab is in focus will move to the next Tab.
Closes #11937
What I have done
EditorTextField
, (EditorTextField()
), that adds anEventFilter
to the relativeTextField
, listening for "tab" presses. If "tab" is pressed it checks if the currentTextField
is the last one of itsTabPane
by callingEntryEditor.checkLastTextField
. This method retrieves the lastField
of the currentTabPane
and compares its name with the ID of theTextField
. If true theTextField
is the last one of itsTabPane
and the nextTabPane
will be selected.The reason the ID of
TextField
should be equal to the name of its correspondingField
is because in classes,PersonsEditor
,SimpleEditor
andCitationKeyEditor
theTextField
created from the originalField
has been set an ID of theField
's display name.How this changes UI experience
After clicking a
TextField
and bringing it to focus, pressing "tab" will cycle through all the succeedingTextFields
(the ones below it) until it reaches the last one and then it will switchTabPane
to the next one toward the right. (see below)Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)