0
我想處理controlsFX 8.0.5框架的AutoCompletionEvent,但不知何故它永遠不會被解僱?!當沒有建議時,應該有一個條目與「新...」,當這個條目被選中時,我想做一些事情。因此我設置了一個EventHandler。JavaFx controlsFX AutoCompletionEvent不起作用
我實現這樣的結合:
AutoCompletionBinding<String> bind = TextFields.bindAutoCompletion(tf, sr -> {
List<String> shownSuggestions = new ArrayList<String>();
for (Client c : suggestions) {
if (!sr.getUserText().isEmpty()
&& c.toString().toLowerCase().startsWith(sr.getUserText().toLowerCase())) {
shownSuggestions.add(c.toString());
}
if (shownSuggestions.isEmpty()) {
if (sr.getUserText().isEmpty()) {
shownSuggestions.add(NEW_PARTY);
} else {
shownSuggestions.add(sr.getUserText() + NEW_PARTY_WITH_NAME);
}
}
}
return shownSuggestions;
});
這是我的事件處理程序:
bind.setOnAutoCompleted(new EventHandler<AutoCompletionEvent<String>>() {
@Override
public void handle(AutoCompletionEvent<String> event) {
if (event.getCompletion().equals(NEW_PARTY)) {
System.out.println("new party chosen");
} else if (event.getCompletion().endsWith(NEW_PARTY_WITH_NAME)) {
System.out.println("new party with input chosen");
}
event.consume();
}
});
但有在控制檯上無輸出。
有人可以幫我嗎?我想這對於現在天...
問候