Skip to content

Commit

Permalink
Update InPlaceEditView.java (#3809)
Browse files Browse the repository at this point in the history
* Update InPlaceEditView.java

- Add support for KEYTAB on physical keyboard
- Add custom client property for TextField component that select all text on focus

* Update InPlaceEditView.java
  • Loading branch information
ImmediandoSrl authored Jun 12, 2024
1 parent bcb6d58 commit 2f18aa0
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Ports/Android/src/com/codename1/impl/android/InPlaceEditView.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;
import android.text.Selection;
import android.text.Editable;
import android.text.InputFilter;
import android.text.InputType;
Expand Down Expand Up @@ -1018,6 +1019,12 @@ public boolean onActionItemClicked(ActionMode mode,
// on a particular text field.
mEditText.setCursorVisible(false);
}

// Set to true if TextField should be selected automatically on focus
if (Boolean.TRUE.equals(textArea.getClientProperty("autoSelectOnFocus"))) {
Editable spannable = mEditText.getText();
Selection.setSelection(spannable, 0, spannable.length());
}

/*
// Leaving this hack here for posterity. It seems that this manually
Expand Down Expand Up @@ -2145,9 +2152,14 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
// If the user presses the back button, or the menu button
// we must terminate editing, to allow EDT to handle events
// again
if (keyCode == KeyEvent.KEYCODE_BACK
|| keyCode == KeyEvent.KEYCODE_MENU) {
endEditing(InPlaceEditView.REASON_SYSTEM_KEY, false, true, 0);
switch(keyCode) {
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_MENU:
endEditing(InPlaceEditView.REASON_SYSTEM_KEY, false, true, 0);
break;
case KeyEvent.KEYCODE_TAB:
onEditorAction(EditorInfo.IME_ACTION_NEXT);
break;
}

return super.onKeyDown(keyCode, event);
Expand Down Expand Up @@ -2190,4 +2202,4 @@ interface ResetableTextWatcher extends TextWatcher {

public void reset();

}
}

0 comments on commit 2f18aa0

Please sign in to comment.