[英]Javafx : TableCell focus lost
我有TableView
,當單元格失去焦點時我想做些事情。 我在此TableView
上啟用了單元格選擇,它不監聽單元格丟失的情況。 我這樣嘗試:
table.getFocusModel().focusedCellProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
//doSomething
}
// else doSomethingElse doesn't work
});
簡而言之,當我取消選擇(按住Ctrl鍵並單擊)單元格時,它不會監聽。 我錯了什么,或者我該如何傾聽失去對TableCell
關注?
我正在使用這個:
TABLEVIEW.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) {
if (newPropertyValue) {
System.out.println("on focus");
} else {
System.out.println("out focus");
}
}
});
僅當您選擇另一個可選元素時才起作用(不起作用,例如,單擊窗格)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.