mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-29 16:01:19 -04:00
added SPACE shortcut to start/stop the simulation
This commit is contained in:
parent
e0200f939f
commit
0da18aee21
@ -70,6 +70,7 @@ import static javax.swing.JOptionPane.showInputDialog;
|
|||||||
*/
|
*/
|
||||||
public final class Main extends JFrame implements ClosingWindowListener.ConfirmSave, ErrorStopper, FileHistory.OpenInterface, DigitalRemoteInterface, StatusInterface {
|
public final class Main extends JFrame implements ClosingWindowListener.ConfirmSave, ErrorStopper, FileHistory.OpenInterface, DigitalRemoteInterface, StatusInterface {
|
||||||
private static final ArrayList<Key> ATTR_LIST = new ArrayList<>();
|
private static final ArrayList<Key> ATTR_LIST = new ArrayList<>();
|
||||||
|
private static final String KEY_START_STOP_ACTION = "startStop";
|
||||||
private static boolean experimental;
|
private static boolean experimental;
|
||||||
|
|
||||||
private static File lastExportDirectory;
|
private static File lastExportDirectory;
|
||||||
@ -752,6 +753,17 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
}
|
}
|
||||||
}.setToolTip(Lang.get("menu_editRunAttributes_tt"));
|
}.setToolTip(Lang.get("menu_editRunAttributes_tt"));
|
||||||
|
|
||||||
|
circuitComponent.getInputMap().put(KeyStroke.getKeyStroke(' '), KEY_START_STOP_ACTION);
|
||||||
|
circuitComponent.getActionMap().put(KEY_START_STOP_ACTION, new AbstractAction() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
|
if (model == null)
|
||||||
|
runModelAction.actionPerformed(actionEvent);
|
||||||
|
else
|
||||||
|
stoppedStateAction.actionPerformed(actionEvent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
JMenu run = new JMenu(Lang.get("menu_sim"));
|
JMenu run = new JMenu(Lang.get("menu_sim"));
|
||||||
menuBar.add(run);
|
menuBar.add(run);
|
||||||
run.add(editRunAttributes.createJMenuItem());
|
run.add(editRunAttributes.createJMenuItem());
|
||||||
|
@ -10,6 +10,7 @@ import java.awt.*;
|
|||||||
public abstract class ToolTipAction extends AbstractAction {
|
public abstract class ToolTipAction extends AbstractAction {
|
||||||
private Icon icon;
|
private Icon icon;
|
||||||
private String toolTipText;
|
private String toolTipText;
|
||||||
|
private KeyStroke accelerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance
|
* Creates a new instance
|
||||||
@ -59,6 +60,17 @@ public abstract class ToolTipAction extends AbstractAction {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an accelerator to the item
|
||||||
|
*
|
||||||
|
* @param accelerator the accelerator
|
||||||
|
* @return this for call chaining
|
||||||
|
*/
|
||||||
|
public ToolTipAction setAccelerator(KeyStroke accelerator) {
|
||||||
|
this.accelerator = accelerator;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the activated state for this action
|
* Sets the activated state for this action
|
||||||
*
|
*
|
||||||
@ -109,6 +121,8 @@ public abstract class ToolTipAction extends AbstractAction {
|
|||||||
*/
|
*/
|
||||||
public JMenuItem createJMenuItem() {
|
public JMenuItem createJMenuItem() {
|
||||||
JMenuItem i = new JMenuItem(this);
|
JMenuItem i = new JMenuItem(this);
|
||||||
|
if (accelerator!=null)
|
||||||
|
i.setAccelerator(accelerator);
|
||||||
if (toolTipText != null) {
|
if (toolTipText != null) {
|
||||||
i.setToolTipText(toolTipText);
|
i.setToolTipText(toolTipText);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user