문제

I want to handle the AutoCompletionEvent of the controlsFX 8.0.5 framework, but somehow it will be never fired?! When no suggestions are available there should be one entry with "new..." and when this entry is chosen I want to do something. Therefore I set an EventHandler.

I implemented the binding like this:

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;
        });

And this is my EventHandler:

            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();
            }
        });

But there is no output on the console.

Can someone please help me? I'm trying this for days now...

regards

도움이 되었습니까?

해결책

There is a bug in controlsFX 8.0.5 causing that the event never gets fired. So the code is correct, but it's never called. Bug report in controlsFX 8.0.5

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top