X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTWindow.java;h=73026953eaa2aa5ffaa5985f6489d9fb1170e2e8;hb=5dfd1c11947e9cb32fcac4772f1b16879d9ffe67;hp=26bd8c453a1922bfd8f79b47c61b35f1470ae429;hpb=c8165631ed92c58eb90b94b80390b5bfaf9b1b6e;p=fanfix.git diff --git a/src/jexer/TWindow.java b/src/jexer/TWindow.java index 26bd8c4..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.