-
-
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
Added gray background text to authors field to assist newcomers #2147
Conversation
7871c8e
to
789bf72
Compare
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.
Looks good from my side 👍
|
||
if (!this.hasFocus() && this.getText().isEmpty()) { | ||
Font prev = g.getFont(); | ||
Color prevColor = g.getColor(); |
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.
Maybe you could rename some variables here.
g- > graphic
h -> height
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.
Done.
super(); | ||
setupUndoRedo(); | ||
setupPasteListener(); | ||
this(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.
Why not ""
instead of 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.
Done.
@@ -151,7 +153,8 @@ private void setupPanel(JabRefFrame frame, BasePanel bPanel, boolean addKeyField | |||
false); | |||
defaultHeight = 0; | |||
} else { | |||
fieldEditor = new TextArea(field, null); | |||
String prompt = (field.equals(FieldName.AUTHOR)) ? Localization.lang("Firstname Lastname and Firstname and Lastname and others") : ""; |
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.
Wrong text
It should be Firstname Lastname and Firstname Lastname
. and others
must not be translated as it is a fixed bibtex term used to write et al.
or something else as configured in the bibtex style.
The rendering of your example is
Lastname, F.; Firstname; Lastname & others
but it should be
Lastname, F.; Lastname, F. & others
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 think, as our "normalize to bibtex name format" formatter will produce "Last, First and Last, First and other", the text should be in this form.
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 changed it to Localization.lang("Firstname Lastname and Firstname Lastname") + " and others"
} | ||
|
||
JTextAreaWithHighlighting(String text) { | ||
super(text); | ||
public JTextAreaWithHighlighting(String text, String title) { |
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 add javadoc comments at least describing title
. Isn't title the textWhenNotFocused
Please rename textWhenNotFocused
to placeholder
to be in line with HTML5 --> http://www.w3schools.com/tags/att_input_placeholder.asp
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.
Done
@koppor This can be achieved with a kind of Custom Component: |
@Siedlerchr thats the way it's currently implemented: Showing/Hiding the hint on FocusGained/FocusLost. But of course, it is also possible to wait for a "KeyPressedEvent" to delete the placeholder. |
The solution to use WebLookAndFeel (http://stackoverflow.com/a/30782629/873282) also looks promising ( |
Can't just the simple solution using |
Using On Oct 11, 2016, 09:32, at 09:32, Oliver Kopp notifications@github.com wrote:
|
@boceckts Are you sure that a |
Only when the text field gets focus. 😇 Could you try at the JavaFX branch? The solution http://stackoverflow.com/a/29946224/873282 looks promising.
and add the 'promptText' entry in fxml file:
No need to recode the whole tabbing, just a small test and if it works, we can decide to postpone a full implementation until javafx is our main UI technology. |
I will give it a try. And yes I think it trigerres when the field loses it's focus. On Oct 11, 2016, 09:40, at 09:40, Oliver Kopp notifications@github.com wrote:
|
fe9235a
to
6f35ff1
Compare
0d654b8
to
cf6afe5
Compare
I changed the behaviour so that the placeholder will always be displayed when the content of the text component is empty. This also means that the "search..." string will also be displayed when nothing is typed even when the search field is focused. I also renamed the classes to As @koppor mentioned, JavaFX TextField element has already a palceholder attribute which worked for me as you would expected. (Same as html5) |
fieldEditor = new TextArea(field, null); | ||
String prompt = ""; | ||
if (field.equals(FieldName.AUTHOR) || field.equals(FieldName.EDITOR)) { | ||
prompt = Localization.lang("Firstname Lastname and Firstname Lastname") + " and others"; |
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'd suggest removing the and
from the localization as well as it is required that it stays and
, therefore making it easier to translate.
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 changed it accordingly.
# Conflicts: # CHANGELOG.md
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.
LGTM
This is not really working on |
@matthiasgeiger what do you mean, what exactly does not work? Is there an exception? I tested it on the current masters branch it works as expected... |
Okay... you are right. Sorry, I tried the last build from https://builds.jabref.org/master which are currently outdated 😞 |
* upstream/master: (24 commits) hotfix NPE in the main table (#2158) Enhance side pane toggle (#1605) Added gray background text to authors field to assist newcomers (#2147) Rewrite google scholar fetcher to new infrastructure (#2101) Found entries will be shown when dropping a pdf with xmp meta data (#2150) Japanese translation (#2155) Add shortcuts to context menu (#2131) [WIP] Doi resolution ignore (#2154) Fix DuplicationChecker and key generator (#2151) just close popup on first ESC keep entry in sight Fix isSharedDatabaseAlreadyPresent check. don't change entry after search if editing an entry (#2129) Change download URL to downloads.jabref.org (#2145) fix switching edited textfield in the entry editor with TAB (#2138) Update me.champeau.gradle.jmh' version from 0.3.0 to 0.3.1 Update install4j plugin from 6.1.2 to 6.1.3 Remove gradle plugin com.github.youribonnaffe.gradle.format as it is deprecated and the config uses a non-existing file Update gradle from 3.0 to 3.1 Fix changing the font size not working when importing preferences (#2069) ... # Conflicts: # src/main/java/net/sf/jabref/gui/externalfiles/DroppedFileHandler.java # src/main/java/net/sf/jabref/gui/importer/fetcher/GoogleScholarFetcher.java
…ef#2147) * Added gray background text to assist newcomers * Display placeholder even when focused * Change placeholder string and include editor field * Update changelog * Fix localization * Refactor localization
I added a gray background text to the "Author" and "Editor" field that appears when the fields don't contain any text. See koppor#61 for reference.
gradle localizationUpdate
?