-
-
Notifications
You must be signed in to change notification settings - Fork 280
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
Search in combo for text with spaces is broken #691
Comments
The fix for the issue is simply to remove that line:
|
This is actually a bug in Swing. Metal, Nimbus and Aqua L&F have the same problem because they also use the Removing the In native macOS apps, the Space key shows the combobox popup. I'll check whether it is possible to fix this without removing the If not, then we either
|
On Windows look and feel, "down" moves to the next item, "alt+down" shows the popup. This search in combo boxes with spaces was reported by some users who had long list of things (people with firstname lastname, some objects with the same first keyword, etc.) and were complaining about the regression with the move to FlatLaf. Do you know if there is an alternative way to remove that mapping without patching the library? |
Sure: UIManager.setLookAndFeel(new FlatLightLaf());
// remove Space key mapping from shared ComboBox input map, which is used for all combo boxes
InputMap inputMap = (InputMap) UIManager.get( "ComboBox.ancestorInputMap" );
if( inputMap != null )
inputMap.remove( KeyStroke.getKeyStroke( "SPACE" ) ); |
Thanks for the sample code! I tried on a combo box in Windows 10 settings and the popup is shown when pressing space only if not currently searching for an item:
I wonder if there is a way in Swing to block the keystroke action if currently in search mode. For the time being, I removed the space key stroke using the code you suggested. |
fixed in latest |
When a combo has the focus (with or without the popup showing), typing text moves the selection to the item matching what is being typed. Unfortunately with FlatLaf this does not work when the item has a space, because hitting space shows or hides the popup.
Searching with keyboard items with a space works with the Windows look and feel.
Here is a simple test case showing the issue:
ComboBoxTest.zip
Just launch, and try to select with the keyboard, for example, "d z":
![image](https://private-user-images.githubusercontent.com/1174202/245854572-0488251f-51d1-4e70-a51f-963baa37ca66.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNTk4NTYsIm5iZiI6MTczOTE1OTU1NiwicGF0aCI6Ii8xMTc0MjAyLzI0NTg1NDU3Mi0wNDg4MjUxZi01MWQxLTRlNzAtYTUxZi05NjNiYWEzN2NhNjYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMDM1MjM2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjFiYWMwNzk5ODY0Y2M3ZWMyM2ExMDM3MGIzNzEyYTNiNWRlNzA3ZjQwNjIyNmYyMmFjZDFlNTE0ODMwYzMwYyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.u4q_HRy8DVDuzIe8ufaYEifrnIaRhuhPsXxZrvEgltQ)
The text was updated successfully, but these errors were encountered: