8274854: Mnemonics for menu containing numeric text not working#647
8274854: Mnemonics for menu containing numeric text not working#647mstr2 wants to merge 8 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into |
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.
Can you verify here which letter / index is picked as mnemonic? (Also in the other tests).
There was a problem hiding this comment.
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.
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.
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.
Just noticed @kleopatra that you suggested the same thing, I definitely agree that the place to test this is in a test for TextBinding.
| int i = 0; | ||
|
|
||
| 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.
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.
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.
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.
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. |
kevinrushforth
left a comment
There was a problem hiding this comment.
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.
| int i = 0; | ||
|
|
||
| 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.
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.
| 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.
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
kevinrushforth
left a comment
There was a problem hiding this comment.
The latest version looks good.
|
The fix and test is fine. |
|
@mstr2 This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. 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. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
/integrate |
|
/sponsor |
|
Going to push as commit 6749ab6.
Your commit was automatically rebased without conflicts. |
|
@kevinrushforth @mstr2 Pushed as commit 6749ab6. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
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
gitCheckout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/647/head:pull/647$ git checkout pull/647Update a local copy of the PR:
$ git checkout pull/647$ git pull https://git.openjdk.java.net/jfx pull/647/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 647View PR using the GUI difftool:
$ git pr show -t 647Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/647.diff