Skip to content
This repository has been archived by the owner on Sep 30, 2018. It is now read-only.

Commit

Permalink
added separate flag for hotkey locking
Browse files Browse the repository at this point in the history
already had an "ignore native inputs" flag which served a dual-purpose:
toggle flag for the menu's lock/unlock setting and also as a temporary
state that was set/unset when opening/closing the edit run and settings
dialogs. problem was that if you locked hotkeys, opened say the settings
dialog and then closed it, the hotkeys would be unlocked during the
dialog close event. this change fixes that behaviour.
  • Loading branch information
gered committed Mar 21, 2016
1 parent bd185d1 commit ae54130
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/fenix/llanfair/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/fenix/llanfair/Llanfair.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,6 +81,7 @@ private Llanfair() {

run = new Run();
runPane = null;
lockedHotkeys = false;
ignoreNativeInputs = false;
preferredSize = null;
actions = new Actions( this );
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit ae54130

Please sign in to comment.