Skip to content
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

8259680: Need API to query states of CAPS LOCK and NUM LOCK keys #385

Closed

Conversation

@kevinrushforth
Copy link
Member

@kevinrushforth kevinrushforth commented Jan 23, 2021

The JavaFX API does not provide a way to get the state of CAPS LOCK or NUM LOCK on the keyboard. Being able to read the lock state would allow an application to inform the user that caps lock was enabled for passwords or other usages where the keyboard input might not be echoed. It would also allow an application to do spell checking / auto-correction that might ordinarily be skipped when typing all upper-case letters.

We need an equivalent JavaFX API to the existing AWT java.awt.ToolKit::getLockingKeyState method. A natural place to put this in JavaFX is in the javafx.application.Platform class, so we propose to create a new Platform::isKeyLocked method, which will take a KeyCode -- either CAPS or NUM_LOCK -- and return an Optional<Boolean> indicating whether or not that key is in the locked or "on" state. If we can't read the key state on a particular platform, we will return Optional.empty(), rather than throwing a runtime exception as AWT does.

I have provided both an automated Robot test and a manual test. The latter is needed primarily because we can't set the CAPS lock on Mac using Robot, but also because we want way to test the case where the user has enabled CAPS lock before the program starts.

/csr needed
/reviewers 2


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8259680: Need API to query states of CAPS LOCK and NUM LOCK keys

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jfx pull/385/head:pull/385
$ git checkout pull/385

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jan 23, 2021

👋 Welcome back kcr! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 23, 2021

@kevinrushforth this pull request will not be integrated until the CSR request JDK-8259868 for issue JDK-8259680 has been approved.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 23, 2021

@kevinrushforth
The number of required reviews for this PR is now set to 2 (with at least 1 of role reviewers).

@mlbridge
Copy link

@mlbridge mlbridge bot commented Jan 23, 2021

@openjdk openjdk bot removed the csr label Jan 29, 2021
Copy link
Member

@arapte arapte left a comment

Looks good to me, verified tests on all three platforms.
Left minor comments.

arapte
arapte approved these changes Jan 29, 2021
Copy link
Member

@arapte arapte left a comment

Looks good. +1

Copy link
Collaborator

@pankaj-bansal pankaj-bansal left a comment

looks good to me

@openjdk
Copy link

@openjdk openjdk bot commented Jan 30, 2021

@kevinrushforth 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:

8259680: Need API to query states of CAPS LOCK and NUM LOCK keys

Reviewed-by: arapte, pbansal

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 3 new commits pushed to the master branch:

  • db6941d: 8256283: IndexOutOfBoundsException when sorting a TreeTableView
  • b0a404d: 8259635: Update to 610.2 version of WebKit
  • 6c1a0ca: 8228363: ContextMenu.show with side=TOP does not work the first time in the presence of CSS

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Jan 30, 2021
@kevinrushforth
Copy link
Member Author

@kevinrushforth kevinrushforth commented Feb 1, 2021

/integrate

@openjdk openjdk bot closed this Feb 1, 2021
@openjdk openjdk bot added integrated and removed ready labels Feb 1, 2021
@openjdk openjdk bot removed the rfr label Feb 1, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 1, 2021

@kevinrushforth Since your change was applied there have been 3 commits pushed to the master branch:

  • db6941d: 8256283: IndexOutOfBoundsException when sorting a TreeTableView
  • b0a404d: 8259635: Update to 610.2 version of WebKit
  • 6c1a0ca: 8228363: ContextMenu.show with side=TOP does not work the first time in the presence of CSS

Your commit was automatically rebased without conflicts.

Pushed as commit 217a8cb.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@kevinrushforth kevinrushforth deleted the 8259680-key-lock branch Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment