JavaFX InputMap / ActionMap等价? [英] JavaFX InputMap/ActionMap equivalent?

查看:168
本文介绍了JavaFX InputMap / ActionMap等价?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我终于完全切换到了JavaFX。

I'm finally switching over fully to JavaFX.

我非常热衷于按键功能。

I'm very keen on keystroke functionality.

是否有一个等效的热键架构(非常好)你在Swing找到的一个?它如何在JavaFX文本控制对象的情况下工作?如果我看一下 javafx.scene.control.TextInputControl ,我认为一切都会变得清晰。当然也尝试使用谷歌搜索。

Is there an equivalent hotkey architecture to the (very good) one you find in Swing? How does it work in the case of a JavaFX text control object? I thought all might become clear if I took a look at javafx.scene.control.TextInputControl. Also tried googling of course.

但我不是更聪明。据推测,在编辑文本时,必须有一个最小击键绑定源?它是否同样是分层的?

But I'm none the wiser. Presumably there must be a source of the minimal keystroke bindings you need when editing text? Is it similarly hierarchical?

使用Swing每个 JComponent 可以使用1 ActionMap 和3 InputMaps (所有这些都可以有祖先地图)。 3 InputMap types由 JComponent 常量确定 WHEN_FOCUSED WHEN_IN_FOCUSED_WINDOW WHEN_ANCESTOR_OF_FOCUSED_COMPONENT 这些是非常不言自明的名字。我真的很想知道有多少Swing用户熟悉所有这些东西,但就个人而言,作为键盘狂热者,我广泛使用这个功能。

With Swing every JComponent can use 1 ActionMap and 3 InputMaps (and all of these can have "ancestor" maps). The 3 InputMap "types" are determined by the JComponent constants WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW and WHEN_ANCESTOR_OF_FOCUSED_COMPONENT which are pretty self-explanatory names. I seriously wonder how many Swing users are familiar with all this stuff but personally, being a keyboard fanatic, I use this functionality extensively.

能够附加一个键绑定到给定 javafx.scene.Node 使用 setOnKeyPressed 大概相当于使用 WHEN_FOCUSED Swing功能......但我想知道其他两个类别呢?它们是否在当前的JavaFX实现中缺席了?

Being able to attach a key binding to a given javafx.scene.Node using setOnKeyPressed is presumably equivalent to using the WHEN_FOCUSED Swing functionality... but what about the other two categories, I wonder? Are they simply absent in the current implementation of JavaFX?

最后,对于Swing,在幕后显然有一种非常复杂的机制,涉及击键被传递到层次结构中 JComponent 对象的结构,直到它们被 InputMap 抓住(或者不是)...可能必须有在JavaFX中有点像这样的东西。有章节和诗歌会很好......

Ultimately, with Swing, behind the scenes there is obviously a very sophisticated mechanism involving keystrokes being "passed up" the hierarchical structure of JComponent objects until they are "caught" by an InputMap (or not)... presumably there must be something a bit like this in JavaFX. It'd be nice to have chapter and verse...

推荐答案

啊哈。

这个问题,从一年前开始已经与Java 9相关,揭示了JavaFX中未来存在的 com.sun.javafx.scene.control.inputmap.InputMap ......显然目前是
com.sun.javafx.scene.control.inputmap 不存在(在Java 8中)(除非我非常误)。

This question, from a year ago, already relating to Java 9, reveals what looks like future existence in JavaFX of com.sun.javafx.scene.control.inputmap.InputMap... obviously at the moment package com.sun.javafx.scene.control.inputmap does not exist (in Java 8) (unless I'm very much mistaken).

提出这个问题的人,Kleopatra,是Java Swing的专家,现在可能是JavaFX。我们看到Java 9的一些早期版本现在正在发生,即2017年3月,正是......但是我已经尝试使用Google Javadoc for JavaFX 9进行谷歌搜索,我还没有看到 com.sun的任何迹象.javafx.scene.control.inputmap.InputMap

The person who posed that question, Kleopatra, is something of an expert in Java Swing, and presumably now in JavaFX. We see some early releases of Java 9 happening around now, March 2017, precisely... but having tried googling for the API Javadoc for JavaFX 9, I can't as yet see any sign of com.sun.javafx.scene.control.inputmap.InputMap.

这篇关于JavaFX InputMap / ActionMap等价?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆