GP-2491 - Updated popup menu key event processing to not apply to combo

boxes
This commit is contained in:
dragonmacher 2022-08-23 13:45:49 -04:00
parent 4ed869ae8d
commit 43f18dcb48

View file

@ -52,8 +52,8 @@ public class MenuKeyProcessor {
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
MenuElement[] path = manager.getSelectedPath();
if (path == null || path.length == 0) {
return false; // no menu showing
if (!hasJPopupMenu(path)) {
return false;
}
KeyStroke eventStroke = KeyStroke.getKeyStrokeForEvent(event);
@ -67,6 +67,22 @@ public class MenuKeyProcessor {
return false;
}
private static boolean hasJPopupMenu(MenuElement[] path) {
if (path == null || path.length == 0) {
return false; // no menu showing
}
// Checking for the exact class seems to be good enough for now. We can update later if
// we find this filters out too many use cases. At the time of writing, we do not want this
// code to apply to all popup windows, such as combo box popups.
for (MenuElement element : path) {
if (element.getClass().equals(JPopupMenu.class)) {
return true;
}
}
return false;
}
private static KeyStroke keyStroke(String s) {
return KeyStroke.getKeyStroke("pressed " + s);
}