add keyboard shortcuts, fix non-mac menu exit

This commit is contained in:
Craig Raw 2020-12-10 08:38:55 +02:00
parent 582065e7f0
commit 94662922a8
2 changed files with 10 additions and 9 deletions

View file

@ -235,6 +235,7 @@ public class AppController implements Initializable {
MenuToolkit tk = MenuToolkit.toolkit(); MenuToolkit tk = MenuToolkit.toolkit();
MenuItem preferences = new MenuItem("Preferences..."); MenuItem preferences = new MenuItem("Preferences...");
preferences.setOnAction(this::openPreferences); preferences.setOnAction(this::openPreferences);
preferences.setAccelerator(new KeyCodeCombination(KeyCode.COMMA, KeyCombination.META_DOWN));
Menu defaultApplicationMenu = new Menu("Apple", null, tk.createAboutMenuItem(MainApp.APP_NAME, getAboutStage()), new SeparatorMenuItem(), Menu defaultApplicationMenu = new Menu("Apple", null, tk.createAboutMenuItem(MainApp.APP_NAME, getAboutStage()), new SeparatorMenuItem(),
preferences, new SeparatorMenuItem(), preferences, new SeparatorMenuItem(),
tk.createHideMenuItem(MainApp.APP_NAME), tk.createHideOthersMenuItem(), tk.createUnhideAllMenuItem(), new SeparatorMenuItem(), tk.createHideMenuItem(MainApp.APP_NAME), tk.createHideOthersMenuItem(), tk.createUnhideAllMenuItem(), new SeparatorMenuItem(),
@ -483,7 +484,7 @@ public class AppController implements Initializable {
public void quit(ActionEvent event) { public void quit(ActionEvent event) {
try { try {
AppServices.get().getApplication().stop(); Platform.exit();
} catch (Exception e) { } catch (Exception e) {
log.error("Error quitting application", e); log.error("Error quitting application", e);
} }

View file

@ -15,26 +15,26 @@
<menus> <menus>
<Menu fx:id="fileMenu" mnemonicParsing="false" text="File"> <Menu fx:id="fileMenu" mnemonicParsing="false" text="File">
<items> <items>
<MenuItem mnemonicParsing="false" text="New Wallet" onAction="#newWallet"/> <MenuItem mnemonicParsing="false" text="New Wallet" accelerator="Shortcut+N" onAction="#newWallet"/>
<MenuItem mnemonicParsing="false" text="Open Wallet..." onAction="#openWallet"/> <MenuItem mnemonicParsing="false" text="Open Wallet..." accelerator="Shortcut+O" onAction="#openWallet"/>
<Menu mnemonicParsing="false" text="Open Transaction"> <Menu mnemonicParsing="false" text="Open Transaction">
<items> <items>
<MenuItem text="File..." onAction="#openTransactionFromFile"/> <MenuItem text="File..." onAction="#openTransactionFromFile" accelerator="Shortcut+T"/>
<MenuItem fx:id="openTransactionIdItem" text="From ID..." onAction="#openTransactionFromId"/> <MenuItem fx:id="openTransactionIdItem" text="From ID..." onAction="#openTransactionFromId"/>
<MenuItem text="From Text..." onAction="#openTransactionFromText"/> <MenuItem text="From Text..." onAction="#openTransactionFromText"/>
<MenuItem text="From QR..." onAction="#openTransactionFromQR"/> <MenuItem text="From QR..." onAction="#openTransactionFromQR"/>
<!-- <MenuItem text="Examples" onAction="#openExamples"/> --> <!-- <MenuItem text="Examples" onAction="#openExamples"/> -->
</items> </items>
</Menu> </Menu>
<MenuItem fx:id="saveTransaction" mnemonicParsing="false" text="Save Transaction..." onAction="#saveTransaction"/> <MenuItem fx:id="saveTransaction" mnemonicParsing="false" text="Save Transaction..." accelerator="Shortcut+S" onAction="#saveTransaction"/>
<SeparatorMenuItem /> <SeparatorMenuItem />
<MenuItem mnemonicParsing="false" text="Import Wallet..." onAction="#importWallet"/> <MenuItem mnemonicParsing="false" text="Import Wallet..." onAction="#importWallet"/>
<MenuItem fx:id="exportWallet" mnemonicParsing="false" text="Export Wallet..." onAction="#exportWallet"/> <MenuItem fx:id="exportWallet" mnemonicParsing="false" text="Export Wallet..." onAction="#exportWallet"/>
<SeparatorMenuItem styleClass="osxHide" /> <SeparatorMenuItem styleClass="osxHide" />
<MenuItem styleClass="osxHide" mnemonicParsing="false" text="Preferences..." onAction="#openPreferences"/> <MenuItem styleClass="osxHide" mnemonicParsing="false" text="Preferences..." accelerator="Shortcut+P" onAction="#openPreferences"/>
<SeparatorMenuItem /> <SeparatorMenuItem />
<MenuItem mnemonicParsing="false" text="Close Tab" onAction="#closeTab"/> <MenuItem mnemonicParsing="false" text="Close Tab" accelerator="Shortcut+W" onAction="#closeTab"/>
<MenuItem styleClass="osxHide" mnemonicParsing="false" text="Quit" onAction="#quit"/> <MenuItem styleClass="osxHide" mnemonicParsing="false" text="Quit" accelerator="Shortcut+Q" onAction="#quit"/>
</items> </items>
</Menu> </Menu>
<fx:define> <fx:define>
@ -85,7 +85,7 @@
</items> </items>
</Menu> </Menu>
<Menu fx:id="toolsMenu" mnemonicParsing="false" text="Tools"> <Menu fx:id="toolsMenu" mnemonicParsing="false" text="Tools">
<MenuItem mnemonicParsing="false" text="Sign/Verify Message" onAction="#signVerifyMessage"/> <MenuItem mnemonicParsing="false" text="Sign/Verify Message" accelerator="Shortcut+M" onAction="#signVerifyMessage"/>
</Menu> </Menu>
<Menu fx:id="helpMenu" mnemonicParsing="false" text="Help"> <Menu fx:id="helpMenu" mnemonicParsing="false" text="Help">
<MenuItem styleClass="osxHide" mnemonicParsing="false" text="About Sparrow" onAction="#showAbout"/> <MenuItem styleClass="osxHide" mnemonicParsing="false" text="About Sparrow" onAction="#showAbout"/>