added separate flag for hotkey locking
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.
This commit is contained in:
parent
bd185d1462
commit
ae54130eaa
|
@ -138,9 +138,9 @@ final class Actions {
|
||||||
} else if ( source == MenuItem.RESET ) {
|
} else if ( source == MenuItem.RESET ) {
|
||||||
reset();
|
reset();
|
||||||
} else if ( source == MenuItem.LOCK ) {
|
} else if ( source == MenuItem.LOCK ) {
|
||||||
master.setIgnoreNativeInputs( true );
|
master.setLockedHotkeys(true);
|
||||||
} else if ( source == MenuItem.UNLOCK ) {
|
} else if ( source == MenuItem.UNLOCK ) {
|
||||||
master.setIgnoreNativeInputs( false );
|
master.setLockedHotkeys(false);
|
||||||
} else if ( source == MenuItem.SETTINGS ) {
|
} else if ( source == MenuItem.SETTINGS ) {
|
||||||
EditSettings dialog = new EditSettings();
|
EditSettings dialog = new EditSettings();
|
||||||
dialog.display( true, master );
|
dialog.display( true, master );
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
|
||||||
|
|
||||||
private JPopupMenu popupMenu;
|
private JPopupMenu popupMenu;
|
||||||
|
|
||||||
|
private volatile boolean lockedHotkeys;
|
||||||
private volatile boolean ignoreNativeInputs;
|
private volatile boolean ignoreNativeInputs;
|
||||||
|
|
||||||
private Dimension preferredSize;
|
private Dimension preferredSize;
|
||||||
|
@ -80,6 +81,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
|
||||||
|
|
||||||
run = new Run();
|
run = new Run();
|
||||||
runPane = null;
|
runPane = null;
|
||||||
|
lockedHotkeys = false;
|
||||||
ignoreNativeInputs = false;
|
ignoreNativeInputs = false;
|
||||||
preferredSize = null;
|
preferredSize = null;
|
||||||
actions = new Actions( this );
|
actions = new Actions( this );
|
||||||
|
@ -183,6 +185,14 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.
|
* Indicates whether or not Llanfair currently ignores all native inputs.
|
||||||
* Since native inputs can be caught even when the application does not have
|
* Since native inputs can be caught even when the application does not have
|
||||||
|
@ -296,7 +306,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
|
||||||
int keyCode = event.getKeyCode();
|
int keyCode = event.getKeyCode();
|
||||||
boolean hotkeysEnabler = ( keyCode == Settings.hotkeyLock.get() );
|
boolean hotkeysEnabler = ( keyCode == Settings.hotkeyLock.get() );
|
||||||
|
|
||||||
if ( !ignoresNativeInputs() || hotkeysEnabler ) {
|
if ( (!areHotkeysLocked() && !ignoresNativeInputs()) || hotkeysEnabler ) {
|
||||||
SwingUtilities.invokeLater( new Runnable() {
|
SwingUtilities.invokeLater( new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
actions.process( event );
|
actions.process( event );
|
||||||
|
|
Reference in a new issue