提交 79197f4e 编写于 作者: L leonidr

8004050: [macosx] The 'ESC' key does not work with jdk8

Reviewed-by: alexsch, serb
上级 c6ac174c
......@@ -281,12 +281,16 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
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 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
/**
* 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 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
/**
* 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 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
}
};
Action highlightFirstAction = new ComboBoxAction() {
private Action highlightFirstAction = new ComboBoxAction() {
@Override
void performComboBoxAction(final AquaComboBoxUI ui) {
listBox.setSelectedIndex(0);
......@@ -338,7 +342,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
}
};
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 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
}
};
Action highlightPageUpAction = new ComboBoxAction() {
private Action highlightPageUpAction = new ComboBoxAction() {
@Override
void performComboBoxAction(final AquaComboBoxUI ui) {
final int current = listBox.getSelectedIndex();
......@@ -367,7 +371,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
}
};
Action highlightPageDownAction = new ComboBoxAction() {
private Action highlightPageDownAction = new ComboBoxAction() {
@Override
void performComboBoxAction(final AquaComboBoxUI ui) {
final int current = listBox.getSelectedIndex();
......@@ -482,13 +486,13 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
// 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 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
}
};
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();
......
/*
* 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 @@ public class AquaKeyBindings {
LateBoundInputMap getComboBoxInputMap() {
return new LateBoundInputMap(new SimpleBinding(new String[] {
"ESCAPE", "hidePopup",
"ESCAPE", "aquaHidePopup",
"PAGE_UP", "aquaSelectPageUp",
"PAGE_DOWN", "aquaSelectPageDown",
"HOME", "aquaSelectHome",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册