X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTWindow.java;h=73026953eaa2aa5ffaa5985f6489d9fb1170e2e8;hb=5dfd1c11947e9cb32fcac4772f1b16879d9ffe67;hp=10f4e59d5df5d946a5d7032475a590552bbdf7ac;hpb=e16dda65585466c8987bd1efd718431450a96605;p=fanfix.git diff --git a/src/jexer/TWindow.java b/src/jexer/TWindow.java index 10f4e59..7302695 100644 --- a/src/jexer/TWindow.java +++ b/src/jexer/TWindow.java @@ -28,6 +28,8 @@ */ package jexer; +import java.util.HashSet; + import jexer.bits.Cell; import jexer.bits.CellAttributes; import jexer.bits.GraphicsChars; @@ -137,6 +139,48 @@ public class TWindow extends TWidget { this.z = z; } + /** + * Window's keyboard shortcuts. Any key in this set will be passed to + * the window directly rather than processed through the menu + * accelerators. + */ + private HashSet keyboardShortcuts = new HashSet(); + + /** + * Add a keypress to be overridden for this window. + * + * @param key the key to start taking control of + */ + protected void addShortcutKeypress(final TKeypress key) { + keyboardShortcuts.add(key); + } + + /** + * Remove a keypress to be overridden for this window. + * + * @param key the key to stop taking control of + */ + protected void removeShortcutKeypress(final TKeypress key) { + keyboardShortcuts.remove(key); + } + + /** + * Remove all keypresses to be overridden for this window. + */ + protected void clearShortcutKeypresses() { + keyboardShortcuts.clear(); + } + + /** + * Determine if a keypress is overridden for this window. + * + * @param key the key to check + * @return true if this window wants to process this key on its own + */ + public boolean isShortcutKeypress(final TKeypress key) { + return keyboardShortcuts.contains(key); + } + /** * If true, then the user clicked on the title bar and is moving the * window. @@ -736,8 +780,8 @@ public class TWindow extends TWidget { if (inKeyboardResize) { - // ESC - Exit size/move - if (keypress.equals(kbEsc)) { + // ESC or ENTER - Exit size/move + if (keypress.equals(kbEsc) || keypress.equals(kbEnter)) { inKeyboardResize = false; }