Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
shai-almog committed Jul 24, 2024
2 parents 9107dc6 + f359bfd commit 56d2119
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
9 changes: 6 additions & 3 deletions CodenameOne/src/com/codename1/ui/TextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -2197,17 +2197,20 @@ public ActionListener getDoneListener() {
* Fire the done event to done listener
*/
public void fireDoneEvent() {
fireDoneEvent(-1);
}
public void fireDoneEvent(final int keyEvent) {
if (doneListener != null) {
if (!Display.getInstance().isEdt()) {
Display.getInstance().callSerially(new Runnable() {

public void run() {
fireDoneEvent();
fireDoneEvent(keyEvent);
}
});
return;
}
doneListener.actionPerformed(new ActionEvent(this,ActionEvent.Type.Done));
doneListener.actionPerformed(new ActionEvent(this,ActionEvent.Type.Done,keyEvent));
}
}

Expand Down
31 changes: 20 additions & 11 deletions Ports/Android/src/com/codename1/impl/android/InPlaceEditView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ public boolean onActionItemClicked(ActionMode mode,
Editable spannable = mEditText.getText();
Selection.setSelection(spannable, 0, spannable.length());
}
/*
// Leaving this hack here for posterity. It seems that this manually
// blinking cursor causes the paste menu to disappear
Expand Down Expand Up @@ -1105,10 +1105,6 @@ private boolean editorContains(int x, int y) {
return mIsEditing && mEditText != null && mEditText.mTextArea != null && mEditText.mTextArea.contains(x, y);
}

private synchronized void endEditing(int reason, boolean forceVKBOpen, int actionCode) {
endEditing(reason, forceVKBOpen, false, actionCode);
}

private Component getNextComponent(Component curr) {
Form f = curr.getComponentForm();
if (f != null) {
Expand All @@ -1117,11 +1113,19 @@ private Component getNextComponent(Component curr) {
return null;
}

private synchronized void endEditing(int reason, boolean forceVKBOpen, int actionCode) {
endEditing(reason, forceVKBOpen, false, actionCode);
}

private synchronized void endEditing(int reason, boolean forceVKBOpen, boolean forceVKBClose, int actionCode) {
endEditing(reason, forceVKBOpen, false, actionCode, -1);
}

/**
* Finish the in-place editing of the given text area, release the edit lock, and allow the synchronous call
* to 'edit' to return.
*/
private synchronized void endEditing(int reason, boolean forceVKBOpen, boolean forceVKBClose, int actionCode) {
private synchronized void endEditing(int reason, boolean forceVKBOpen, boolean forceVKBClose, int actionCode, int keyEvent) {
//if (cursorTimer != null) {
// cursorTimer.cancel();
//}
Expand Down Expand Up @@ -1167,11 +1171,9 @@ private synchronized void endEditing(int reason, boolean forceVKBOpen, boolean f
if (reason == REASON_IME_ACTION
&& ((TextArea) mEditText.mTextArea).getDoneListener() != null
&& (actionCode == EditorInfo.IME_ACTION_DONE)|| actionCode == EditorInfo.IME_ACTION_SEARCH || actionCode == EditorInfo.IME_ACTION_SEND || actionCode == EditorInfo.IME_ACTION_GO) {
((TextArea) mEditText.mTextArea).fireDoneEvent();

((TextArea) mEditText.mTextArea).fireDoneEvent(keyEvent);
}


// Call this in onComplete instead
//mIsEditing = false;
mLastEditText = mEditText;
Expand Down Expand Up @@ -1256,7 +1258,7 @@ public void run() {
if (fHasNext && fNext != null) {
Display.getInstance().callSerially(new Runnable() {
public void run() {
final Form f = fNext.getComponentForm();
final Form f = fNext.getComponentForm();
if (f == null) {
return;
}
Expand All @@ -1268,7 +1270,8 @@ public void actionPerformed(ActionEvent evt) {
fNext.startEditingAsync();
}
});

if(EditorInfo.IME_ACTION_NEXT == fActionCode)
fNext.requestFocus();
}
});
}
Expand Down Expand Up @@ -2157,6 +2160,12 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
case KeyEvent.KEYCODE_MENU:
endEditing(InPlaceEditView.REASON_SYSTEM_KEY, false, true, 0);
break;
case KeyEvent.KEYCODE_ENTER:
onEditorAction(EditorInfo.IME_ACTION_DONE);
break;
case KeyEvent.KEYCODE_ESCAPE:
endEditing(InPlaceEditView.REASON_IME_ACTION, false, true, EditorInfo.IME_ACTION_DONE, keyCode);
break;
case KeyEvent.KEYCODE_TAB:
onEditorAction(EditorInfo.IME_ACTION_NEXT);
break;
Expand Down

0 comments on commit 56d2119

Please sign in to comment.