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()
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToMenu
(JPopupMenu menu) void
boolean
match
(MenuElement e, String str) boolean
void
void
void
void
void
void
void
processFound
(MenuSelectionManager manager, MenuElement[] found, String str) boolean
void
processTarget
(MenuSelectionManager manager, String str) void
run
(MenuKeyEvent e) searchDown
(MenuElement[] path, MenuElement[] children, MenuElement stopAt, String str) searchUp
(MenuElement[] path, String str)
-
Field Details
-
buffer
-
-
Constructor Details
-
MenuKeySelector
public MenuKeySelector()
-
-
Method Details
-
addToMenu
-
popupMenuWillBecomeVisible
- Specified by:
popupMenuWillBecomeVisible
in interfacePopupMenuListener
-
popupMenuWillBecomeInvisible
- Specified by:
popupMenuWillBecomeInvisible
in interfacePopupMenuListener
-
popupMenuCanceled
- Specified by:
popupMenuCanceled
in interfacePopupMenuListener
-
clearBuffer
public void clearBuffer() -
run
-
processKeyInput
-
processTarget
-
processFound
-
searchDown
public MenuElement[] searchDown(MenuElement[] path, MenuElement[] children, MenuElement stopAt, String str) -
searchUp
-
match
-
matchText
-