• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java InputMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.fxmisc.wellbehaved.event.InputMap的典型用法代码示例。如果您正苦于以下问题:Java InputMap类的具体用法?Java InputMap怎么用?Java InputMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InputMap类属于org.fxmisc.wellbehaved.event包,在下文中一共展示了InputMap类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: apply

import org.fxmisc.wellbehaved.event.InputMap; //导入依赖的package包/类
@Override
public <T extends LayoutCell<?>> void apply(VirtualFlow<T> list,
                                            Relation relation) {

    Nodes.addInputMap(list, InputMap.consume(DOUBLE_SELECT, e -> {
        Route route = back.peek()
                          .getRoute(relation);
        if (route == null) {
            return;
        }
        JsonNode item = list.getSelectionModel()
                            .getSelectedItem();
        if (item == null) {
            return;
        }
        try {
            push(extract(route, item));
        } catch (QueryException ex) {
            log.error("Unable to push page: %s", route.getPath(), ex);
        }
    }));
}
 
开发者ID:ChiralBehaviors,项目名称:Kramer,代码行数:23,代码来源:SinglePageApp.java


示例2: CustomCodeArea

import org.fxmisc.wellbehaved.event.InputMap; //导入依赖的package包/类
public CustomCodeArea(String text, Highlight highlight, Syntax syntax, String name) {
    executor = Executors.newSingleThreadExecutor();
    this.highlight = highlight;
    this.syntax = syntax;
    this.lastText = "";
    this.name = name;

    InputMap<Event> prevent = InputMap.consume(
            anyOf(
                    keyPressed(TAB, SHORTCUT_ANY, SHIFT_ANY)
            )
    );
    Nodes.addInputMap(this, prevent);

    this.setOnKeyPressed(event -> {
        if (event.getCode() == KeyCode.TAB) {
            this.insertText(this.getCaretPosition(), "    ");
        }
    });
    caretPosition = CaretPosition.create();
    this.caretPositionProperty().addListener(listener -> caretPosition.compute(this));
    this.setParagraphGraphicFactory(LineNumberFactory.get(this));
    this.richChanges()
            .filter(this::isChangeable)
            .successionEnds(Duration.ofMillis(20))
            .supplyTask(this::computeHighlightingAsync)
            .awaitLatest(this.richChanges())
            .filterMap(this::getOptional)
            .subscribe(this::applyHighlighting);
    this.replaceText(0, 0, text);
}
 
开发者ID:MrChebik,项目名称:Coconut-IDE,代码行数:32,代码来源:CustomCodeArea.java


示例3: start

import org.fxmisc.wellbehaved.event.InputMap; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
    Layout model = new Layout() {
        @Override
        public <T extends LayoutCell<?>> void apply(VirtualFlow<T> list,
                                                    Relation relation) {
            Nodes.addInputMap(list,
                              InputMap.consume(DOUBLE_SELECT,
                                               e -> System.out.println("event: "
                                                                       + list.getSelectionModel()
                                                                             .getSelectedItem())));
        }
    };
    AutoLayout layout = new AutoLayout(Util.build(), model);
    URL url = getClass().getResource("/bootstrap3.css");
    if (url != null) {
        layout.getStylesheets()
              .add(url.toExternalForm());
    }
    AnchorPane.setTopAnchor(layout, 0.0);
    AnchorPane.setLeftAnchor(layout, 0.0);
    AnchorPane.setBottomAnchor(layout, 0.0);
    AnchorPane.setRightAnchor(layout, 0.0);
    AnchorPane root = new AnchorPane();
    root.getChildren()
        .add(layout);
    primaryStage.setScene(new Scene(root, 800, 800));
    primaryStage.show();

    JsonNode data = Util.testData();
    layout.measure(data);
    layout.updateItem(data);
    layout.autoLayout();
}
 
开发者ID:ChiralBehaviors,项目名称:Kramer,代码行数:35,代码来源:Smoke.java


示例4: from

import org.fxmisc.wellbehaved.event.InputMap; //导入依赖的package包/类
static <S, E extends Event> HandlerTemplateConsumer<S, E> from(
        InputMap.HandlerConsumer<E> hc, S target) {
    return new HandlerTemplateConsumer<S, E>() {
        @Override
        public <F extends E> void accept(
                EventType<? extends F> t, InputHandlerTemplate<S, ? super F> h) {
            hc.accept(t, evt -> h.process(target, evt));

        }
    };
}
 
开发者ID:FXMisc,项目名称:WellBehavedFX,代码行数:12,代码来源:InputMapTemplate.java


示例5: test

import org.fxmisc.wellbehaved.event.InputMap; //导入依赖的package包/类
@Test
public void test() {
    StringProperty res = new SimpleStringProperty();

    InputMapTemplate<Node, KeyEvent> imt1 = consume(keyPressed(A), (s, e) -> res.set("A"));
    InputMapTemplate<Node, KeyEvent> imt2 = consume(keyPressed(B), (s, e) -> res.set("B"));
    InputMapTemplate<Node, KeyEvent> imt = imt1.orElse(imt2);
    InputMap<KeyEvent> ignA = InputMap.ignore(keyPressed(A));

    Node node1 = new Region();
    Node node2 = new Region();

    Nodes.addInputMap(node1, ignA);
    InputMapTemplate.installFallback(imt, node1);
    InputMapTemplate.installFallback(imt, node2);

    KeyEvent aPressed = new KeyEvent(KEY_PRESSED, "", "", A, false, false, false, false);
    KeyEvent bPressed = new KeyEvent(KEY_PRESSED, "", "", B, false, false, false, false);

    InputMapTest.dispatch(aPressed, node1);
    assertNull(res.get());
    assertFalse(aPressed.isConsumed());

    InputMapTest.dispatch(aPressed, node2);
    assertEquals("A", res.get());
    assertTrue(aPressed.isConsumed());

    InputMapTest.dispatch(bPressed, node1);
    assertEquals("B", res.get());
    assertTrue(bPressed.isConsumed());
}
 
开发者ID:FXMisc,项目名称:WellBehavedFX,代码行数:32,代码来源:InputMapTemplateTest.java


示例6: apply

import org.fxmisc.wellbehaved.event.InputMap; //导入依赖的package包/类
@Override
public <T extends LayoutCell<?>> void apply(VirtualFlow<T> list,
                                            Relation relation) {
    Nodes.addInputMap(list, InputMap.consume(DOUBLE_SELECT, e -> {
        doubleClick(list.getSelectionModel()
                        .getSelectedItem(),
                    relation);
    }));
}
 
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:10,代码来源:UniversalApplication.java


示例7: instantiate

import org.fxmisc.wellbehaved.event.InputMap; //导入依赖的package包/类
/**
 * Converts this InputMapTemplate into an {@link InputMap} for the given {@code target}
 */
public final InputMap<E> instantiate(S target) {
    return new InputMapTemplateInstance<>(this, target);
}
 
开发者ID:FXMisc,项目名称:WellBehavedFX,代码行数:7,代码来源:InputMapTemplate.java


示例8: start

import org.fxmisc.wellbehaved.event.InputMap; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
    InlineCssTextArea area = new InlineCssTextArea();

    InputMap<Event> preventSelectionOrRightArrowNavigation = InputMap.consume(
            anyOf(
                    // prevent selection via (CTRL + ) SHIFT + [LEFT, UP, DOWN]
                    keyPressed(LEFT,    SHIFT_DOWN, SHORTCUT_ANY),
                    keyPressed(KP_LEFT, SHIFT_DOWN, SHORTCUT_ANY),
                    keyPressed(UP,    SHIFT_DOWN, SHORTCUT_ANY),
                    keyPressed(KP_UP, SHIFT_DOWN, SHORTCUT_ANY),
                    keyPressed(DOWN,    SHIFT_DOWN, SHORTCUT_ANY),
                    keyPressed(KP_DOWN, SHIFT_DOWN, SHORTCUT_ANY),

                    // prevent selection via mouse events
                    eventType(MouseEvent.MOUSE_DRAGGED),
                    eventType(MouseEvent.DRAG_DETECTED),
                    mousePressed().unless(e -> e.getClickCount() == 1 && !e.isShiftDown()),

                    // prevent any right arrow movement, regardless of modifiers
                    keyPressed(RIGHT,     SHORTCUT_ANY, SHIFT_ANY),
                    keyPressed(KP_RIGHT,  SHORTCUT_ANY, SHIFT_ANY)
            )
    );
    Nodes.addInputMap(area, preventSelectionOrRightArrowNavigation);

    area.replaceText(String.join("\n",
            "You can't move the caret to the right via the RIGHT arrow key in this area.",
            "Additionally, you cannot select anything either",
            "",
            ":-p"
    ));
    area.moveTo(0);

    CheckBox addExtraEnterHandlerCheckBox = new CheckBox("Temporarily add an EventHandler to area's `onKeyPressedProperty`?");
    addExtraEnterHandlerCheckBox.setStyle("-fx-font-weight: bold;");

    Label checkBoxExplanation = new Label(String.join("\n",
            "The added handler will insert a newline character at the caret's position when [Enter] is pressed.",
            "If checked, the default behavior and added handler will both occur: ",
            "\tthus, two newline characters should be inserted when user presses [Enter].",
            "When unchecked, the handler will be removed."
    ));
    checkBoxExplanation.setWrapText(true);

    EventHandler<KeyEvent> insertNewlineChar = e -> {
        if (e.getCode().equals(ENTER)) {
            area.insertText(area.getCaretPosition(), "\n");
            e.consume();
        }
    };
    addExtraEnterHandlerCheckBox.selectedProperty().addListener(
            (obs, ov, isSelected) -> area.setOnKeyPressed( isSelected ? insertNewlineChar : null)
    );

    VBox vbox = new VBox(area, addExtraEnterHandlerCheckBox, checkBoxExplanation);
    vbox.setSpacing(10);
    vbox.setPadding(new Insets(10));

    primaryStage.setScene(new Scene(vbox, 700, 350));
    primaryStage.show();
    primaryStage.setTitle("An area whose behavior has been overridden permanently and temporarily!");
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:64,代码来源:OverrideBehaviorDemo.java



注:本文中的org.fxmisc.wellbehaved.event.InputMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EnterPreviewRowsDialog类代码示例发布时间:2022-05-22
下一篇:
Java ParamUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap