diff --git a/src/main/java/org/fenix/llanfair/Language.java b/src/main/java/org/fenix/llanfair/Language.java index d3e8ece..8429479 100644 --- a/src/main/java/org/fenix/llanfair/Language.java +++ b/src/main/java/org/fenix/llanfair/Language.java @@ -51,8 +51,7 @@ public enum Language { setting_hotkey_pause, setting_hotkey_lock, GLOBAL_HOTKEYS_WARNING, - GLOBAL_HOTKEYS_HOOK_RETRY, - GLOBAL_HOTKEYS_HOOK_ERROR, + GLOBAL_HOTKEYS_STARTUP_WARNING, // Settings > Header setting_header_goal, diff --git a/src/main/java/org/fenix/llanfair/Llanfair.java b/src/main/java/org/fenix/llanfair/Llanfair.java index 20f712c..11eb256 100644 --- a/src/main/java/org/fenix/llanfair/Llanfair.java +++ b/src/main/java/org/fenix/llanfair/Llanfair.java @@ -472,7 +472,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener, * Attempts to register a hook to capture system-wide (global) key events. * @return true if the hook was registered, false if not */ - public static boolean registerNativeKeyHook() { + public boolean registerNativeKeyHook() { try { GlobalScreen.registerNativeHook(); return true; @@ -481,6 +481,8 @@ public class Llanfair extends BorderlessFrame implements TableModelListener, // to pop up an OS-specific dialog or other action that allows the user to rectify the // problem. e.g. on OS X, if an exception is thrown a dialog telling the user that the // application has requested some accessibility-related access shows up. + + JOptionPane.showMessageDialog(this, Language.GLOBAL_HOTKEYS_WARNING, Language.ERROR.get(), JOptionPane.ERROR_MESSAGE); return false; } } diff --git a/src/main/java/org/fenix/llanfair/dialog/TabHotkeys.java b/src/main/java/org/fenix/llanfair/dialog/TabHotkeys.java index 0c23fb1..fa70d2b 100644 --- a/src/main/java/org/fenix/llanfair/dialog/TabHotkeys.java +++ b/src/main/java/org/fenix/llanfair/dialog/TabHotkeys.java @@ -1,7 +1,6 @@ package org.fenix.llanfair.dialog; import org.fenix.llanfair.Language; -import org.fenix.llanfair.Llanfair; import org.fenix.llanfair.config.Settings; import org.fenix.utils.gui.GBC; import org.jnativehook.GlobalScreen; @@ -25,7 +24,6 @@ class TabHotkeys extends SettingsTab { private JCheckBox globalHotKeys; private JLabel globalHotKeysHookWarning; - private JButton globalHotKeysHookRetryButton; /** * List of all key fields customizable by the user. @@ -54,19 +52,6 @@ class TabHotkeys extends SettingsTab { globalHotKeysHookWarning = new JLabel("" + Language.GLOBAL_HOTKEYS_WARNING); globalHotKeysHookWarning.setForeground(Color.RED); - globalHotKeysHookRetryButton = new JButton("" + Language.GLOBAL_HOTKEYS_HOOK_RETRY); - globalHotKeysHookRetryButton.addActionListener(new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - boolean isRegistered = Llanfair.registerNativeKeyHook(); - if (isRegistered) { - globalHotKeysHookWarning.setVisible(false); - globalHotKeysHookRetryButton.setVisible(false); - } else { - JOptionPane.showMessageDialog(that, Language.GLOBAL_HOTKEYS_HOOK_ERROR, Language.ERROR.get(), JOptionPane.ERROR_MESSAGE); - } - } - }); keyFields = new ArrayList(); keyLabels = new ArrayList(); @@ -113,10 +98,8 @@ class TabHotkeys extends SettingsTab { add(globalHotKeys, GBC.grid(2, 3).insets(0, 50, 0, 0).anchor(GBC.LS)); - if (!GlobalScreen.isNativeHookRegistered()) { + if (GlobalScreen.isNativeHookRegistered()) add(globalHotKeysHookWarning, GBC.grid(0, row + 1, 3, 1).insets(10, 0, 10, 0)); - add(globalHotKeysHookRetryButton, GBC.grid(0, row + 2, 3, 1).insets(0, 0, 10, 0)); - } } // --------------------------------------------------------- INTERNAL TYPES diff --git a/src/main/resources/language.properties b/src/main/resources/language.properties index bbdb4aa..d633e8f 100644 --- a/src/main/resources/language.properties +++ b/src/main/resources/language.properties @@ -31,9 +31,8 @@ setting_hotkey_reset = Reset setting_hotkey_stop = Stop setting_hotkey_pause = Pause setting_hotkey_lock = Lock / Unlock -GLOBAL_HOTKEYS_WARNING =
Key event hook registration failed. You will not be able to set or use any of your hotkeys until this is fixed! Click 'Retry' below to attempt to register it again.
-GLOBAL_HOTKEYS_HOOK_RETRY = Retry -GLOBAL_HOTKEYS_HOOK_ERROR = Key event hook registration failed. You will need to grant extra accessibility permissions to Llanfair. +GLOBAL_HOTKEYS_WARNING =
Key event hook registration failed. You will not be able to set or use any of your hotkeys until this is fixed! To fix this, you will probably need to grant Llanfair some extended accessibility permissions from your operating system and then restart Llanfair.
+GLOBAL_HOTKEYS_STARTUP_WARNING = Key event hook registration failed. You will not be able to set or use any of your hotkeys until this is fixed! To fix this, you will probably need to grant Llanfair some extended accessibility permissions from your operating system and then restart Llanfair. # Settings > Header setting_header_goal = Display Goal