BUG: First time BACKSPACE hit isn't deleting character in TextField

Inside a TextField, clicking on text then hitting BACKSPACE will not delete ANY character, although subsequent hit will properly work.

I’ve taken a quick look into that class and… shudder This is totally not the way I’d do things tbh. But, that’s not my place to tell others how to do their own things. Nonetheless I’ll try to find where the problem is to fix it. I just won’t spend too long trying to find the problem.

So, in the end it’s more of an FYI than anything else. But, it’s possible I might find the problem fast. Who knows. :stuck_out_tongue:

This fixes the issue. Should be safe, it’s up to you.
[java]# This patch file was generated by NetBeans IDE

It uses platform neutral UTF-8 encoding and \n newlines.

— Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -295,19 +295,22 @@
meta = true;
} else if (evt.getKeyCode() == KeyInput.KEY_RETURN) {
} else if (evt.getKeyCode() == KeyInput.KEY_DELETE) {

  •   	if (rangeHead != -1 && rangeTail != -1)	editTextRangeText("");
    
  •   	else {
    
  •   		if (caretIndex < finalText.length()) textFieldText.remove(caretIndex);
    
  •   	if (rangeHead != -1 && rangeTail != -1)	{
    
  •                        editTextRangeText("");
    
  •                        deleteKey(caretIndex);
    
  •                    } else {
    
  •   		if (caretIndex < finalText.length()) {
    
  •                                deleteKey(caretIndex);
    

+// textFieldText.remove(caretIndex);
}

  •   	}
      } else if (evt.getKeyCode() == KeyInput.KEY_BACK) {
      	if (rangeHead != -1 && rangeTail != -1) {
      		editTextRangeText("");
    
  •                            deleteKey(caretIndex - 1);
      	} else {
    
  •   		if (caretIndex > 0) {
    
  •   			textFieldText.remove(caretIndex-1);
    
  •   			caretIndex--;
    
  •   		deleteKey(caretIndex - 1);
      		}
    
  •   	}
      } else if (evt.getKeyCode() == KeyInput.KEY_LEFT) {
      	if (!shift) resetTextRange();
      	if (caretIndex > -1) {
    

@@ -489,6 +492,15 @@
evt.setConsumed();
}

  •    private void deleteKey(int index) {
    
  •        if (caretIndex >= 0 && index >= 0) {
    
  •            textFieldText.remove(index);
    
  •            caretIndex--;
    
  •        }
    
  •        if (caretIndex < 0) {
    
  •            caretIndex = 0;
    
  •        }
    
  •    }
    
    /**
    • An overridable hook for the onKeyPress event of the TextField
    • @param evt KeyInputEvent
      [/java]

Diff now fixes both Backspace and Delete behavior of not erasing the first time they are used.

1 Like

I’ll get this in today at some point.

Where you able to get the image issue resolved?

@madjack said: Inside a TextField, clicking on text then hitting BACKSPACE will not delete ANY character, although subsequent hit will properly work.

I’ve taken a quick look into that class and… shudder This is totally not the way I’d do things tbh. But, that’s not my place to tell others how to do their own things. Nonetheless I’ll try to find where the problem is to fix it. I just won’t spend too long trying to find the problem.

So, in the end it’s more of an FYI than anything else. But, it’s possible I might find the problem fast. Who knows. :stuck_out_tongue:

I’m more than open to suggestions. What would you do differently?

@t0neg0d said: I'll get this in today at some point.
Ok. It's possible there are side-effect(s) to this, but I think it's doing fine. I haven't tested it very thoroughly.
Where you able to get the image issue resolved?
I -think- so. Problem is, I need to have 2 saved games to get their own screenshots. And, since I'm doing an InputBox for the naming of new worlds, I'm waiting until all those pieces are completed to test the whole thing.

Speaking of InputBox, that’s the thing I want to give you. It’s similar to DialogBox except it’s used to input text. Note that it won’t have as much functionality as your own controls, but you’re free to make it proper once I’m done with it.

Anyway, I’m not done yet.

1 Like
@madjack said: Ok. It's possible there are side-effect(s) to this, but I think it's doing fine. I haven't tested it very thoroughly.

I -think- so. Problem is, I need to have 2 saved games to get their own screenshots. And, since I’m doing an InputBox for the naming of new worlds, I’m waiting until all those pieces are completed to test the whole thing.

Speaking of InputBox, that’s the thing I want to give you. It’s similar to DialogBox except it’s used to input text. Note that it won’t have as much functionality as your own controls, but you’re free to make it proper once I’m done with it.

Anyway, I’m not done yet.

Oooo… this sound good! Looking forward to seeing it!!