OpenJDK / portola / portola
changeset 20470:555b46436610
8004050: [macosx] The 'ESC' key does not work with jdk8
Reviewed-by: alexsch, serb
author | leonidr |
---|---|
date | Wed, 09 Oct 2013 01:03:33 +0400 |
parents | 47a792bd7dbf |
children | 5f3e7611790a 1250b4720a9c |
files | jdk/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java jdk/src/macosx/classes/com/apple/laf/AquaKeyBindings.java |
diffstat | 2 files changed, 28 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java Tue Oct 08 23:34:20 2013 +0400 +++ b/jdk/src/macosx/classes/com/apple/laf/AquaComboBoxUI.java Wed Oct 09 01:03:33 2013 +0400 @@ -281,12 +281,16 @@ actionMap.put("aquaSelectPageUp", highlightPageUpAction); actionMap.put("aquaSelectPageDown", highlightPageDownAction); + actionMap.put("aquaHidePopup", hideAction); + SwingUtilities.replaceUIActionMap(comboBox, actionMap); } - abstract class ComboBoxAction extends AbstractAction { + private abstract class ComboBoxAction extends AbstractAction { public void actionPerformed(final ActionEvent e) { - if (!comboBox.isEnabled() || !comboBox.isShowing()) return; + if (!comboBox.isEnabled() || !comboBox.isShowing()) { + return; + } if (comboBox.isPopupVisible()) { final AquaComboBoxUI ui = (AquaComboBoxUI)comboBox.getUI(); @@ -302,7 +306,7 @@ /** * Hilight _but do not select_ the next item in the list. */ - Action highlightNextAction = new ComboBoxAction() { + private Action highlightNextAction = new ComboBoxAction() { @Override public void performComboBoxAction(AquaComboBoxUI ui) { final int si = listBox.getSelectedIndex(); @@ -318,7 +322,7 @@ /** * Hilight _but do not select_ the previous item in the list. */ - Action highlightPreviousAction = new ComboBoxAction() { + private Action highlightPreviousAction = new ComboBoxAction() { @Override void performComboBoxAction(final AquaComboBoxUI ui) { final int si = listBox.getSelectedIndex(); @@ -330,7 +334,7 @@ } }; - Action highlightFirstAction = new ComboBoxAction() { + private Action highlightFirstAction = new ComboBoxAction() { @Override void performComboBoxAction(final AquaComboBoxUI ui) { listBox.setSelectedIndex(0); @@ -338,7 +342,7 @@ } }; - Action highlightLastAction = new ComboBoxAction() { + private Action highlightLastAction = new ComboBoxAction() { @Override void performComboBoxAction(final AquaComboBoxUI ui) { final int size = listBox.getModel().getSize(); @@ -347,7 +351,7 @@ } }; - Action highlightPageUpAction = new ComboBoxAction() { + private Action highlightPageUpAction = new ComboBoxAction() { @Override void performComboBoxAction(final AquaComboBoxUI ui) { final int current = listBox.getSelectedIndex(); @@ -367,7 +371,7 @@ } }; - Action highlightPageDownAction = new ComboBoxAction() { + private Action highlightPageDownAction = new ComboBoxAction() { @Override void performComboBoxAction(final AquaComboBoxUI ui) { final int current = listBox.getSelectedIndex(); @@ -482,13 +486,13 @@ // This is somewhat messy. The difference here from BasicComboBoxUI.EnterAction is that // arrow up or down does not automatically select the - static final Action triggerSelectionAction = new AbstractAction() { + private static final Action triggerSelectionAction = new AbstractAction() { public void actionPerformed(final ActionEvent e) { triggerSelectionEvent((JComboBox)e.getSource(), e); } }; - static final Action toggleSelectionAction = new AbstractAction() { + private static final Action toggleSelectionAction = new AbstractAction() { public void actionPerformed(final ActionEvent e) { final JComboBox comboBox = (JComboBox)e.getSource(); if (!comboBox.isEnabled()) return; @@ -506,6 +510,18 @@ } }; + private static Action hideAction = new AbstractAction() { + @Override + public void actionPerformed(final ActionEvent e) { + final JComboBox comboBox = (JComboBox)e.getSource(); + + if (comboBox.isPopupVisible()) { + comboBox.firePopupMenuCanceled(); + comboBox.setPopupVisible(false); + } + } + }; + public void applySizeFor(final JComponent c, final Size size) { if (arrowButton == null) return; final Border border = arrowButton.getBorder();
--- a/jdk/src/macosx/classes/com/apple/laf/AquaKeyBindings.java Tue Oct 08 23:34:20 2013 +0400 +++ b/jdk/src/macosx/classes/com/apple/laf/AquaKeyBindings.java Wed Oct 09 01:03:33 2013 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -209,7 +209,7 @@ LateBoundInputMap getComboBoxInputMap() { return new LateBoundInputMap(new SimpleBinding(new String[] { - "ESCAPE", "hidePopup", + "ESCAPE", "aquaHidePopup", "PAGE_UP", "aquaSelectPageUp", "PAGE_DOWN", "aquaSelectPageDown", "HOME", "aquaSelectHome",