In reference to this old thread about text_changed event to a combobox.
This is throwing an error:
Compiling generated Java code. Error
B4J line: 133
End Sub
javac 1.8.0_60
src\b4j\example\clscompanies.java:350: error: non-static variable ba cannot be referenced from a static context
ba.raiseEventFromUI(box, EventName.toLowerCase() + "_textchanged", newValue);
^
1 error
in a class Initialize Sub:
Update: This thread was originally posted in the Code Snippets forum *by mistake* and has now been recreated here to, hopefully, get a helpful response for anyone in the future that runs across it. I've abandoned B4J's combobox and am now using a combination of jmons' QuickTextSelect and a custom control to much better effect.
This is throwing an error:
Compiling generated Java code. Error
B4J line: 133
End Sub
javac 1.8.0_60
src\b4j\example\clscompanies.java:350: error: non-static variable ba cannot be referenced from a static context
ba.raiseEventFromUI(box, EventName.toLowerCase() + "_textchanged", newValue);
^
1 error
in a class Initialize Sub:
B4X:
cmbState.Items.AddAll(Array As String("AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY"))
' To give me a text_changed event in order to simulate a jump-to feature on this combobox
Dim jo As JavaObject = Me
jo.RunMethod("AddTextChanged", Array(cmbState, "cmbState"))
#If Java
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.ComboBox;
import anywheresoftware.b4a.BA;
public static void AddTextChanged(final ComboBox box, final String EventName) {
box.getEditor().textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue) {
ba.raiseEventFromUI(box, EventName.toLowerCase() + "_textchanged", newValue);
}
});
}
#End If
End Sub
Sub cmdState_TextChanged (Text As String)
Log(Text)
End Sub
Update: This thread was originally posted in the Code Snippets forum *by mistake* and has now been recreated here to, hopefully, get a helpful response for anyone in the future that runs across it. I've abandoned B4J's combobox and am now using a combination of jmons' QuickTextSelect and a custom control to much better effect.