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
8274854: Mnemonics for menu containing numeric text not working #647
Conversation
|
Webrevs
|
/reviewers 2 |
@kevinrushforth |
modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/TextBinding.java
Outdated
Show resolved
Hide resolved
label.setText("_foo _bar _qux"); | ||
label.autosize(); | ||
skin.updateDisplayedText(); | ||
assertEquals("foo _bar _qux", LabelSkinBaseShim.getText(label).getText()); |
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.
Can you verify here which letter / index is picked as mnemonic? (Also in the other tests).
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 don't see an easy way to do that, and I'm not in favor of making private implementation details package-public just to test some internal state. Of course, mnemonic support should have been designed in a way that is more easily testable, but this PR is not the place to do that.
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.
in the skin test, it could be tested indirectly, though not in isolation:
- access the actual mnenomic via accessibleAttribute
- test whether labelFor/action is working as expected when firing an alt-mnemonic onto the scene
Just noticed that there is no test of TextBinding .. that's where the correct working of the basics should be tested, shouldn't it?
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.
How about adding a JUnit test for TextBinding instead? The class is sufficiently complicated to warrant one, and it has quite a few branches to cover. I think testing it through a Control
is a bit too high level.
Something like:
TextBinding tb = new TextBinding("complicated_mnemonic__example_(s)__");
assertEquals("m", tb.getMnemonic());
assertEquals(KeyCombination.M, tb.getMnemonicKeyCombination());
assertEquals(12, tb.getMnemonicIndex());
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.
Just noticed @kleopatra that you suggested the same thing, I definitely agree that the place to test this is in a test for TextBinding
.
|
||
for (int i = 0, length = s.length(); i < length; ++i) { | ||
// Parse the input string and stop after the first mnemonic. |
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.
This seems to do much more than just fixing numeric mnemonics. Now it stops after the first mnemonic, whereas it picked the last mnemonic before this change (which seems to be a regression from what happened in jfx16).
I think the regression should be fixed first, then additional features can be added?
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.
This PR does not add any additional feature. It restores the behavior of jfx16, where any character is acceptable as a mnemonic, and the first mnemonic is selected.
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.
Okay, the wording of the JBS ticket suggested something else, but I see it is just a regression fix.
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.
Yes, exactly. There were two bugs introduced with the previous fix: First, digits or other symbols are no longer recognized as mnemonics. Second, the last _
is used rather than the first. It looks like this fixes both problems.
there is no need for the class rename, is there? Even though it's formally internal api, I think we shouldn't do code breaking changes except if there's a very compelling reason - there are too many apps out in the wild that use internal api. |
I don't know how |
Well, internal interfaces aren't API. With JDK 9 - 16 it requires relaxing encapsulation to get at it. As of JDK 17, it requires an explicit export of the package to access it. Having said that, since this is a fix we are likely to want to backport to at least JavaFX 17.0.X, I think we should minimize the scope of the fix. So I agree with @kleopatra (albeit for a different reason) that we shouldn't make this change. |
Agreed.
Completely agree.
Yes, but I would prefer to see it as a separate fix, rather than as part of a (critical) regression bug fix. |
The latest changes look good (aside from the renaming of the class, which could be done separately). I'll look at the refactored tests and do some more testing next week.
|
||
for (int i = 0, length = s.length(); i < length; ++i) { | ||
// Parse the input string and stop after the first mnemonic. |
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.
Yes, exactly. There were two bugs introduced with the previous fix: First, digits or other symbols are no longer recognized as mnemonics. Second, the last _
is used rather than the first. It looks like this fixes both problems.
@@ -191,6 +191,7 @@ private void parseAndSplit(String s) { | |||
builder.append(s.charAt(i++)); | |||
} else if (isExtendedMnemonic(s, i)) { | |||
mnemonic = String.valueOf(s.charAt(i + 2)); | |||
mnemonicIndex = i; |
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.
Good catch. This is needed to make extended mnemonics work.
modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/MnemonicParser.java
Outdated
Show resolved
Hide resolved
The fix and test is fine. |
@mstr2 This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 23 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@aghaisas, @kevinrushforth) but any other Committer may sponsor as well.
|
/integrate |
/sponsor |
Going to push as commit 6749ab6.
Your commit was automatically rebased without conflicts. |
@kevinrushforth @mstr2 Pushed as commit 6749ab6. |
This PR fixes an issue with mnemonic parsing by removing the restriction that a mnemonic symbol must be a letter. Now, it can be any character except whitespace.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/647/head:pull/647
$ git checkout pull/647
Update a local copy of the PR:
$ git checkout pull/647
$ git pull https://git.openjdk.java.net/jfx pull/647/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 647
View PR using the GUI difftool:
$ git pr show -t 647
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/647.diff