mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-321188 Make the Enter key perform apply action when the focus is on the template list
GitOrigin-RevId: 2e29988a80187fe99f12a3a8d106add95ddf53c1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9d88127c50
commit
a08b01a489
+10
-6
@@ -123,12 +123,7 @@ public class NewItemSimplePopupPanel extends JBPanel implements Disposable {
|
||||
res.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
if (myApplyAction == null) return;
|
||||
try (AccessToken ignore = SlowOperations.startSection(SlowOperations.ACTION_PERFORM)) {
|
||||
myApplyAction.consume(e);
|
||||
}
|
||||
}
|
||||
performApplyActionOnEnter(e);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -142,6 +137,15 @@ public class NewItemSimplePopupPanel extends JBPanel implements Disposable {
|
||||
return res;
|
||||
}
|
||||
|
||||
protected void performApplyActionOnEnter(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
if (myApplyAction == null) return;
|
||||
try (AccessToken ignore = SlowOperations.startSection(SlowOperations.ACTION_PERFORM)) {
|
||||
myApplyAction.consume(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasError() {
|
||||
return myErrorPopup != null;
|
||||
}
|
||||
|
||||
+7
-7
@@ -17,7 +17,7 @@ import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
@@ -54,19 +54,19 @@ public class NewItemWithTemplatesPopupPanel<T> extends NewItemSimplePopupPanel {
|
||||
else {
|
||||
setFocusCycleRoot(true);
|
||||
setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
|
||||
textField.addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) { }
|
||||
|
||||
textField.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e != null && (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP)) {
|
||||
textField.transferFocus();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
myTemplatesList.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) { }
|
||||
public void keyPressed(KeyEvent e) {
|
||||
performApplyActionOnEnter(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user