diff --git a/src/main/java/org/fenix/llanfair/Actions.java b/src/main/java/org/fenix/llanfair/Actions.java index a57f823..ff348b9 100644 --- a/src/main/java/org/fenix/llanfair/Actions.java +++ b/src/main/java/org/fenix/llanfair/Actions.java @@ -138,9 +138,9 @@ void process( ActionEvent event ) { } else if ( source == MenuItem.RESET ) { reset(); } else if ( source == MenuItem.LOCK ) { - master.setIgnoreNativeInputs( true ); + master.setLockedHotkeys(true); } else if ( source == MenuItem.UNLOCK ) { - master.setIgnoreNativeInputs( false ); + master.setLockedHotkeys(false); } else if ( source == MenuItem.SETTINGS ) { EditSettings dialog = new EditSettings(); dialog.display( true, master ); diff --git a/src/main/java/org/fenix/llanfair/Llanfair.java b/src/main/java/org/fenix/llanfair/Llanfair.java index 46bc1f3..335b84e 100644 --- a/src/main/java/org/fenix/llanfair/Llanfair.java +++ b/src/main/java/org/fenix/llanfair/Llanfair.java @@ -53,6 +53,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener, private JPopupMenu popupMenu; + private volatile boolean lockedHotkeys; private volatile boolean ignoreNativeInputs; private Dimension preferredSize; @@ -80,6 +81,7 @@ private Llanfair() { run = new Run(); runPane = null; + lockedHotkeys = false; ignoreNativeInputs = false; preferredSize = null; actions = new Actions( this ); @@ -183,6 +185,14 @@ public final void setRun( Run run ) { } } + public synchronized boolean areHotkeysLocked() { + return lockedHotkeys; + } + + public synchronized void setLockedHotkeys(boolean lockedHotkeys) { + this.lockedHotkeys = lockedHotkeys; + } + /** * Indicates whether or not Llanfair currently ignores all native inputs. * Since native inputs can be caught even when the application does not have @@ -296,7 +306,7 @@ private static void dumpLocalization() { int keyCode = event.getKeyCode(); boolean hotkeysEnabler = ( keyCode == Settings.hotkeyLock.get() ); - if ( !ignoresNativeInputs() || hotkeysEnabler ) { + if ( (!areHotkeysLocked() && !ignoresNativeInputs()) || hotkeysEnabler ) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { actions.process( event );