Order of Events Listeners

0

I have a tableView with a listener when selecting a new row from the table view, and I have a textfield that gets a value from one of the tableView columns;

The textfield has a listenter when losing the focus of the field it updates the value of the selected row in the tableview;

The problem occurs when I change the value of the textfield and I select a new line that the event of selecting the new line overlaps the listener of the text field;

How could I define that the event of losing the textfield focus will always be executed before the tableView listener?

Event that controls the focus of the text field, when leaving the field it changes the values in the tableView:

txtValorVenda.focusedProperty().addListener(new ChangeListener<Boolean>() {
    @Override
    public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue,
            Boolean newPropertyValue) {

        if (!newPropertyValue) {
            if (!btnInsert.isPressed() && !btnClose.isPressed() && !btnCancel.isPressed()){

                tbViewPrecosEmp.getSelectionModel().getSelectedItem().setVlrVendaVarejo(Util.decimalBRtoBigDecimal(2,txtValorVenda.getText()));
                tbViewPrecosEmp.refresh();


            }
        }
    }
});

Event that controls the selection of an item in the tableView. When a row is selected, it loads the tableView values into the corresponding textfields:

tbViewPrecosEmp.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> {
    if (newSelection != null) {
        // CARREGA OS DADOS DA LINHA SELECIONADA OBJETO INSTANCIADO
            txtCusto.setText(tbViewPrecosEmp.getSelectionModel().getSelectedItem().getVlrCusto().toString());
            txtMargem.setText(tbViewPrecosEmp.getSelectionModel().getSelectedItem().getMargemLucroVarejo().toString());
            txtValorVenda.setText(tbViewPrecosEmp.getSelectionModel().getSelectedItem().getVlrVendaVarejo().toString());
    }
});

The problem is when the user populates a new value in the textField, and clicks on a new selection in the tableView so that the event of the tableview executes first that of the missing focus of the text field.

    
asked by anonymous 29.04.2017 / 17:12

0 answers