X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTApplication.java;h=971f6f8fa572ff243645975966243dc9ff25f598;hb=5dfd1c11947e9cb32fcac4772f1b16879d9ffe67;hp=0a2ab19548f7a1706b3dec7656803bd7c478fb57;hpb=c8165631ed92c58eb90b94b80390b5bfaf9b1b6e;p=nikiroo-utils.git diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 0a2ab19..971f6f8 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -965,20 +965,35 @@ public class TApplication implements Runnable { if (event instanceof TKeypressEvent) { TKeypressEvent keypress = (TKeypressEvent) event; - // See if this key matches an accelerator, and if so dispatch the - // menu event. - TKeypress keypressLowercase = keypress.getKey().toLowerCase(); - TMenuItem item = null; - synchronized (accelerators) { - item = accelerators.get(keypressLowercase); + // See if this key matches an accelerator, and is not being + // shortcutted by the active window, and if so dispatch the menu + // event. + boolean windowWillShortcut = false; + for (TWindow window: windows) { + if (window.isActive()) { + if (window.isShortcutKeypress(keypress.getKey())) { + // We do not process this key, it will be passed to + // the window instead. + windowWillShortcut = true; + } + } } - if (item != null) { - if (item.isEnabled()) { - // Let the menu item dispatch - item.dispatch(); - return; + + if (!windowWillShortcut) { + TKeypress keypressLowercase = keypress.getKey().toLowerCase(); + TMenuItem item = null; + synchronized (accelerators) { + item = accelerators.get(keypressLowercase); + } + if (item != null) { + if (item.isEnabled()) { + // Let the menu item dispatch + item.dispatch(); + return; + } } } + // Handle the keypress if (onKeypress(keypress)) { return; @@ -1659,7 +1674,7 @@ public class TApplication implements Runnable { * * @param event new event to add to the queue */ - public final void addMenuEvent(final TInputEvent event) { + public final void postMenuEvent(final TInputEvent event) { synchronized (fillEventQueue) { fillEventQueue.add(event); } @@ -1745,11 +1760,8 @@ public class TApplication implements Runnable { if (activeMenu != null) { return; } - - synchronized (windows) { - for (TWindow window: windows) { - closeWindow(window); - } + while (windows.size() > 0) { + closeWindow(windows.get(0)); } }