Module org.autogui

Class PopupExtension.MenuKeySelector

java.lang.Object
org.autogui.swing.util.PopupExtension.MenuKeySelector
All Implemented Interfaces:
EventListener, MenuKeyListener, PopupMenuListener
Enclosing class:
PopupExtension

public static class PopupExtension.MenuKeySelector extends Object implements MenuKeyListener, PopupMenuListener
a menu-selector by incremental key-typing
     new MenuKeySelector().addToMenu(popupMenu);
 

select menu items by key types

  • any displayable key : put it into the buffer and select a next item. if no item is found, search from the top
  • backspace, delete: clear the buffer
  • tab: no change for the buffer and search a next item
  • newline, arrow-keys, ... : no consumption of the key event

The order of the search is children of the current item, rest sibling items, children of rest sibling items (recursion) ... , upper rest items, children of upper rest items (recursion), ...

Matching : it uses startsWith for JMenuItem's getText()