--- old/modules/web/src/main/java/com/sun/javafx/scene/web/behavior/HTMLEditorBehavior.java 2015-09-03 15:14:26.670565300 -0700 +++ new/modules/web/src/main/java/com/sun/javafx/scene/web/behavior/HTMLEditorBehavior.java 2015-09-03 15:14:26.110533300 -0700 @@ -25,49 +25,45 @@ package com.sun.javafx.scene.web.behavior; -import javafx.scene.web.HTMLEditor; -import java.util.ArrayList; -import java.util.List; import com.sun.javafx.scene.control.behavior.BehaviorBase; -import com.sun.javafx.scene.control.behavior.KeyBinding; +import com.sun.javafx.scene.control.inputmap.InputMap; +import com.sun.javafx.scene.control.inputmap.KeyBinding; +import javafx.scene.web.HTMLEditor; import com.sun.javafx.scene.web.skin.HTMLEditorSkin; -import static javafx.scene.input.KeyCode.B; -import static javafx.scene.input.KeyCode.F12; -import static javafx.scene.input.KeyCode.I; -import static javafx.scene.input.KeyCode.TAB; -import static javafx.scene.input.KeyCode.U; +import com.sun.javafx.scene.control.behavior.FocusTraversalInputMap; +import static javafx.scene.input.KeyCode.*; +import static com.sun.javafx.scene.control.inputmap.InputMap.KeyMapping; /** * HTML editor behavior. */ public class HTMLEditorBehavior extends BehaviorBase { - protected static final List HTML_EDITOR_BINDINGS = new ArrayList(); + private final InputMap inputMap; - static { - HTML_EDITOR_BINDINGS.add(new KeyBinding(B, "bold").shortcut()); - HTML_EDITOR_BINDINGS.add(new KeyBinding(I, "italic").shortcut()); - HTML_EDITOR_BINDINGS.add(new KeyBinding(U, "underline").shortcut()); - - HTML_EDITOR_BINDINGS.add(new KeyBinding(F12, "F12")); - HTML_EDITOR_BINDINGS.add(new KeyBinding(TAB, "TraverseNext").ctrl()); - HTML_EDITOR_BINDINGS.add(new KeyBinding(TAB, "TraversePrevious").ctrl().shift()); - } public HTMLEditorBehavior(HTMLEditor htmlEditor) { - super(htmlEditor, HTML_EDITOR_BINDINGS); + super(htmlEditor); + + this.inputMap = createInputMap(); + addDefaultMapping(inputMap, + new KeyMapping(new KeyBinding(B).shortcut(), e -> keyboardShortcuts("bold")), + new KeyMapping(new KeyBinding(I).shortcut(), e -> keyboardShortcuts("italic")), + new KeyMapping(new KeyBinding(U).shortcut(), e -> keyboardShortcuts("underline")), + + new KeyMapping(new KeyBinding(F12), e -> getNode().getImpl_traversalEngine().selectFirst().requestFocus()), + new KeyMapping(new KeyBinding(TAB).ctrl(), FocusTraversalInputMap::traverseNext), + new KeyMapping(new KeyBinding(TAB).ctrl().shift(), FocusTraversalInputMap::traversePrevious) + ); + } + + @Override public InputMap getInputMap() { + return inputMap; } - @Override - protected void callAction(String name) { - if ("bold".equals(name) || "italic".equals(name) || "underline".equals(name)) { - HTMLEditor editor = getControl(); - HTMLEditorSkin editorSkin = (HTMLEditorSkin)editor.getSkin(); - editorSkin.keyboardShortcuts(name); - } else if ("F12".equals(name)) { - getControl().getImpl_traversalEngine().selectFirst().requestFocus(); - } else { - super.callAction(name); - } + private void keyboardShortcuts(String name) { + HTMLEditor editor = getNode(); + HTMLEditorSkin editorSkin = (HTMLEditorSkin)editor.getSkin(); + editorSkin.keyboardShortcuts(name); } }