这是我的代码:
AssociationOverrides({
@AssociationOverride(name = "folder_documents_compositeKey.folder", joinColumns = @JoinColumn(name = "folder_id")),
@AssociationOverride(name = "folder_documents_compositeKey.document", joinColumns = {
@JoinColumn(name = "doc_id" , referencedColumnName = "id") ,
@JoinColumn(name = "matricule" , referencedColumnName = "matricule") })})
我希望实现以下代码来处理聚焦子事件
@Override
void start(Stage stage) throws Exception {
def root = new VBox() {
{
children.add(new TextArea() {
{
setId("ta1")
}
})
children.add(new TextArea() {
{
setId("ta2")
}
})
}
}
root.setOnFocus(new OnFocus() {
void onFocus(Node focusedTarget) {
// handle focusedTarget
}
})
def scene = new Scene(root, 800, 600)
stage.setScene(scene)
stage.show()
}
如果我设置#ta1和#ta2的focusedProperty,如果孩子很大,很难做到,所以我希望直接听父母,怎么做?
答案 0 :(得分:1)
标准事件分派可用于在Scene
上触发自定义事件。可以使用位于focusOwner
的{{1}}属性的侦听器来触发事件。
Scene
public class FocusEvent extends Event {
public static final EventType FOCUS_EVENT_TYPE = new EventType(EventType.ROOT);
public FocusEvent(Object source, EventTarget target) {
super(source, target, FOCUS_EVENT_TYPE);
}
}