java.lang.Object
org.autogui.swing.GuiSwingKeyBinding
a class for automatic key-stroke assignments.
It relies on
KeyboardFocusManager which can steel key-events globally.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfacestatic classstatic classstatic classa set of key-precedence information: a key-precedence becomes a flag value (GuiSwingKeyBinding.KeyPrecedenceFlagwhich indicates the type of action, or a view-depth (GuiSwingKeyBinding.KeyPrecedenceDepth).static classstatic classstatic classstatic classstatic classa predefined key-binding by the component UIstatic classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<GuiSwingKeyBinding.KeyStrokeAction> protected GuiSwingKeyBinding.KeyBindDispatcherprotected Map<KeyStroke, Map<GuiSwingKeyBinding.KeyPrecedenceSet, List<GuiSwingKeyBinding.KeyStrokeAction>>> user specified a key-stroke by the GuiIncluded(keyStroke=...) annotationstatic intstatic intstatic intstatic intprotected List<BiConsumer<GuiSwingKeyBinding, Component>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddDefaultExcludedKey(int k, int mod) voidassign()voidbind(JComponent component) booleanbind(KeyStroke key, Map<GuiSwingKeyBinding.KeyPrecedenceSet, List<GuiSwingKeyBinding.KeyStrokeAction>> precToActions) static booleancheckMenuModifiersMask(int constKey, int testedMods) static KeyStrokecopyWithModifiers(KeyStroke stroke, int mod) static GuiSwingKeyBindingstatic GuiSwingKeyBindingstatic KeyStrokegetKeyStroke(String key) putForComponentInputMap(JComponent c, int depth) putForValuePane(GuiSwingView.ValuePane<?> pane, int depth) <CompType extends JComponent>
GuiSwingKeyBindingputHighPrecedence(CompType c, KeyStroke keyStroke, Consumer<CompType> f) putHighPrecedenceAction(JComponent c, KeyStroke keyStroke, Action action) putHighPrecedencePaneFocus(JComponent c, KeyStroke keyStroke) booleanputItem(GuiSwingView.ValuePane<?> pane, int depth, PopupCategorized.CategorizedMenuItem item) booleanputItemRecommended(GuiSwingView.ValuePane<?> pane, int depth, GuiSwingKeyBinding.RecommendedKeyStroke item) booleanputKeyStroke(GuiSwingView.ValuePane<?> pane, int depth, PopupCategorized.CategorizedMenuItem i, Action item) booleanputKeyStrokeFocus(GuiSwingView.ValuePane<?> pane, int depth, KeyStroke stroke) <T extends Component>
GuiSwingKeyBindingputTraverse(Class<T> type, Predicate<T> predicate, BiConsumer<GuiSwingKeyBinding, T> put) append a traversal function for setting key-strokes for a specified component by a given function.<CompType extends JComponent>
GuiSwingKeyBindingputTraverseHighPrecedence(Class<CompType> type, Predicate<CompType> predicate, KeyStroke keyStroke, Consumer<CompType> f) append a traversal function for setting a function with a key-stroke for a specific component.<CompType extends JComponent>
GuiSwingKeyBindingputTraverseHighPrecedenceAction(Class<CompType> type, Predicate<CompType> predicate, KeyStroke keyStroke, Action action) append a traversal function for setting an action with a key-stroke for a specific component.<CompType extends JComponent>
GuiSwingKeyBindingputTraverseHighPrecedencePaneFocus(Class<CompType> type, Predicate<CompType> predicate, KeyStroke keyStroke) append a traversal function for setting focus action with a key-stroke for a specific component.voidDeprecated.voidsetDispatcher(JComponent component) traverseKeyBinding(Component c, int depth) voidunbind()Deprecated.voidunbind(JComponent component)
-
Field Details
-
traverseFunctions
-
keyToPrecToActions
protected Map<KeyStroke,Map<GuiSwingKeyBinding.KeyPrecedenceSet, keyToPrecToActionsList<GuiSwingKeyBinding.KeyStrokeAction>>> -
assigned
-
assignedKeys
-
dispatcher
-
PRECEDENCE_TYPE_FLAG_HIGH
public static int PRECEDENCE_TYPE_FLAG_HIGH -
PRECEDENCE_TYPE_FLAG_USER_SPECIFIED
public static int PRECEDENCE_TYPE_FLAG_USER_SPECIFIED -
PRECEDENCE_TYPE_DEPTH
public static int PRECEDENCE_TYPE_DEPTH -
PRECEDENCE_TYPE_FLAG_LIB_SPECIFIED
public static int PRECEDENCE_TYPE_FLAG_LIB_SPECIFIED -
PRECEDENCE_FLAG_HIGH
-
PRECEDENCE_FLAG_USER_SPECIFIED
user specified a key-stroke by the GuiIncluded(keyStroke=...) annotation -
PRECEDENCE_FLAG_LIB_SPECIFIED
-
PRECEDENCE_SET_INPUT_MAP
-
-
Constructor Details
-
GuiSwingKeyBinding
public GuiSwingKeyBinding()
-
-
Method Details
-
createWithDefaultExcluded
- Returns:
- a default key-binding with excluding some keys by
addDefaultExcluded()and with default traversing function byaddTraverseFunctionDefault().
-
createWithoutAutomaticBindings
- Returns:
- a key-binding without automatic traversing and bindings
-
putTraverseHighPrecedencePaneFocus
public <CompType extends JComponent> GuiSwingKeyBinding putTraverseHighPrecedencePaneFocus(Class<CompType> type, Predicate<CompType> predicate, KeyStroke keyStroke) append a traversal function for setting focus action with a key-stroke for a specific component.GuiSwingKeyBinding.createWithoutAutomaticBindings() .putTraverseHighPrecedencePaneFocus(ValuePane.class, vp -> vp.getSwingViewContext().getName().equals("prop"), GuiSwingKeyBinding.getKeyStroke("shift X"))- Type Parameters:
CompType- the component type- Parameters:
type- the component typepredicate- predicate for specifying the componentkeyStroke- the key-stroke for focusing- Returns:
- this
-
putTraverseHighPrecedenceAction
public <CompType extends JComponent> GuiSwingKeyBinding putTraverseHighPrecedenceAction(Class<CompType> type, Predicate<CompType> predicate, KeyStroke keyStroke, Action action) append a traversal function for setting an action with a key-stroke for a specific component.GuiSwingKeyBinding.createWithoutAutomaticBindings() .putTraverseHighPrecedenceAction(ValuePane.class, vp -> vp.getSwingViewContext().getName().equals("prop"), GuiSwingKeyBinding.getKeyStroke("shift X"), action)- Type Parameters:
CompType- the component type- Parameters:
type- the component typepredicate- predicate for specifying the componentkeyStroke- the key-stroke for the actionaction- the action executed by the key-stroke- Returns:
- this
-
putTraverseHighPrecedence
public <CompType extends JComponent> GuiSwingKeyBinding putTraverseHighPrecedence(Class<CompType> type, Predicate<CompType> predicate, KeyStroke keyStroke, Consumer<CompType> f) append a traversal function for setting a function with a key-stroke for a specific component.GuiSwingKeyBinding.createWithoutAutomaticBindings() .putTraverseHighPrecedence(ValuePane.class, vp -> vp.getSwingViewContext().getName().equals("prop"), GuiSwingKeyBinding.getKeyStroke("shift X"), comp -> System.out.println(comp))- Type Parameters:
CompType- the component type- Parameters:
type- the component typepredicate- predicate for specifying the componentkeyStroke- the key-stroke for the functionf- the function executed by the key-stroke- Returns:
- this
-
putTraverse
public <T extends Component> GuiSwingKeyBinding putTraverse(Class<T> type, Predicate<T> predicate, BiConsumer<GuiSwingKeyBinding, T> put) append a traversal function for setting key-strokes for a specified component by a given function. the binding will be happen only the first component matched by the predicate.- Type Parameters:
T- the component type- Parameters:
type- the component typepredicate- predicate for specifying the componentput- a function for setting up key-strokes for the component- Returns:
- this
-
putHighPrecedencePaneFocus
-
putHighPrecedenceAction
-
putHighPrecedence
public <CompType extends JComponent> GuiSwingKeyBinding putHighPrecedence(CompType c, KeyStroke keyStroke, Consumer<CompType> f) -
addTraverseFunctionDefault
-
addTraverseFunction
-
getKeyStroke
-
copyWithModifiers
-
bind
-
addDefaultExcluded
-
addDefaultExcludedKey
-
addKeyBindingForComponentTree
-
traverseKeyBinding
-
putForValuePane
-
putForComponentInputMap
-
putForComponentInputMap
-
assign
public void assign() -
putItem
public boolean putItem(GuiSwingView.ValuePane<?> pane, int depth, PopupCategorized.CategorizedMenuItem item) -
putItemRecommended
public boolean putItemRecommended(GuiSwingView.ValuePane<?> pane, int depth, GuiSwingKeyBinding.RecommendedKeyStroke item) -
putKeyStroke
public boolean putKeyStroke(GuiSwingView.ValuePane<?> pane, int depth, PopupCategorized.CategorizedMenuItem i, Action item) -
putKeyStrokeFocus
-
putKeyStroke
-
checkMenuModifiersMask
public static boolean checkMenuModifiersMask(int constKey, int testedMods) -
bind
public boolean bind(KeyStroke key, Map<GuiSwingKeyBinding.KeyPrecedenceSet, List<GuiSwingKeyBinding.KeyStrokeAction>> precToActions) -
setDispatcher
Deprecated. -
setDispatcher
- Parameters:
component- the root pane- Since:
- 1.4
-
unbind
Deprecated. -
unbind
- Parameters:
component- the root pane, the former parameter ofsetDispatcher(JComponent)- Since:
- 1.4
-
getDispatcher
-
getAssigned
-
getAssignedFromDispatcher
-