[fixes #1088] Set 'Enter' hotkey for recovery and separation tables

This commit is contained in:
Sibo Van Gool 2022-01-30 14:05:53 +01:00
parent b26ae9e541
commit 65927d485b
2 changed files with 26 additions and 1 deletions

View File

@ -2,14 +2,18 @@ package net.sf.openrocket.gui.main.flightconfigpanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
@ -59,6 +63,15 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
}
});
this.add(resetDeploymentButton, "sizegroup button, wrap");
// Set 'Enter' key action to open the recovery selection dialog
table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter");
table.getActionMap().put("Enter", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent ae) {
selectDeployment();
}
});
}
@Override

View File

@ -2,14 +2,18 @@ package net.sf.openrocket.gui.main.flightconfigpanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
@ -63,6 +67,14 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
});
this.add(resetDeploymentButton, "sizegroup button, wrap");
// Set 'Enter' key action to open the separation selection dialog
table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter");
table.getActionMap().put("Enter", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent ae) {
selectSeparation();
}
});
}
@Override