I am developing a form with ComboBox as a subject (the user can choose one from the list , or type one)
and TextArea where the user can write his notes
The user using a virtual keyboard (touch) to enter any characters.
(I am using the append method to append the next Char to the TextInputControl class (both Combo and TextArea Inherit from it
When I try to deletePreviousChar() in the TextArea it works, but in ComboBox it fails
I put some System.out.println() (I am an old fashion guy) to see what is the problem and it seems that with the ComboBox the class is loosing the Caret position after every action
Here is my code:
public void changed(ObservableValue<? extends String> observable,
String oldVal, String newVal) {
if (newVal != null) {
if (lastNodeInFocus instanceof TextArea) {
switch (newVal) {
case Keyboard.KEY_CODE_DLT_PREV_CHAR:
System.out.println("TA - dlt :" + notes.getCaretPosition());
notes.deletePreviousChar();
break;
default:
System.out.println("TA - Append B :" + notes.getCaretPosition());
notes.appendText(newVal);
System.out.println("TA - Append A :" + notes.getCaretPosition());
break;
}
}else{
switch (newVal) {
case Keyboard.KEY_CODE_DLT_PREV_CHAR:
System.out.println("CB - dlt :" + topTenSubjects.editorProperty().getValue().getCaretPosition());
System.out.println(topTenSubjects.editorProperty().getValue().deletePreviousChar());
break;
default:
System.out.println("CB - append B :" + topTenSubjects.editorProperty().getValue().getCaretPosition());
topTenSubjects.editorProperty().getValue().appendText(newVal);
System.out.println("CB - append A :" + topTenSubjects.editorProperty().getValue().getCaretPosition());
break;
}
}
keyboard.keyPressed.set(null);
}
Here is the Debug results: CB = Combo TA = TextArea B=Before A=After , the numbers are the caret position
CB - append B 0
CB - append A :1
CB - append B 0
CB - append A :2
CB - append B 0
CB - append A :3
CB - append B 0
CB - append A :4
CB - dlt 0
false
CB - dlt 0
false
TA - Append B 0
TA - Append A :1
TA - Append B :1
TA - Append A :2
TA - Append B :2
TA - Append A :3
TA - Append B :3
TA - Append A :4
TA - dlt :4
TA - dlt :3
TA - dlt :2
TA - dlt :1
and TextArea where the user can write his notes
The user using a virtual keyboard (touch) to enter any characters.
(I am using the append method to append the next Char to the TextInputControl class (both Combo and TextArea Inherit from it
When I try to deletePreviousChar() in the TextArea it works, but in ComboBox it fails
I put some System.out.println() (I am an old fashion guy) to see what is the problem and it seems that with the ComboBox the class is loosing the Caret position after every action
Here is my code:
public void changed(ObservableValue<? extends String> observable,
String oldVal, String newVal) {
if (newVal != null) {
if (lastNodeInFocus instanceof TextArea) {
switch (newVal) {
case Keyboard.KEY_CODE_DLT_PREV_CHAR:
System.out.println("TA - dlt :" + notes.getCaretPosition());
notes.deletePreviousChar();
break;
default:
System.out.println("TA - Append B :" + notes.getCaretPosition());
notes.appendText(newVal);
System.out.println("TA - Append A :" + notes.getCaretPosition());
break;
}
}else{
switch (newVal) {
case Keyboard.KEY_CODE_DLT_PREV_CHAR:
System.out.println("CB - dlt :" + topTenSubjects.editorProperty().getValue().getCaretPosition());
System.out.println(topTenSubjects.editorProperty().getValue().deletePreviousChar());
break;
default:
System.out.println("CB - append B :" + topTenSubjects.editorProperty().getValue().getCaretPosition());
topTenSubjects.editorProperty().getValue().appendText(newVal);
System.out.println("CB - append A :" + topTenSubjects.editorProperty().getValue().getCaretPosition());
break;
}
}
keyboard.keyPressed.set(null);
}
Here is the Debug results: CB = Combo TA = TextArea B=Before A=After , the numbers are the caret position
CB - append B 0
CB - append A :1
CB - append B 0
CB - append A :2
CB - append B 0
CB - append A :3
CB - append B 0
CB - append A :4
CB - dlt 0
false
CB - dlt 0
false
TA - Append B 0
TA - Append A :1
TA - Append B :1
TA - Append A :2
TA - Append B :2
TA - Append A :3
TA - Append B :3
TA - Append A :4
TA - dlt :4
TA - dlt :3
TA - dlt :2
TA - dlt :1