Skip to content

Commit

Permalink
Merge pull request #5741 from hieupham007/timob-16893
Browse files Browse the repository at this point in the history
[timob-16893]: Android update doc and behavior for 'enableReturnKey' property
  • Loading branch information
vishalduggal committed Jul 29, 2014
2 parents 166f33d + 637ed07 commit c8c9e43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent keyEvent)
Log.d(TAG, "ActionID: " + actionId + " KeyEvent: " + (keyEvent != null ? keyEvent.getKeyCode() : null),
Log.DEBUG_MODE);

boolean enableReturnKey = false;
if (proxy.hasProperty(TiC.PROPERTY_ENABLE_RETURN_KEY)) {
enableReturnKey = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_ENABLE_RETURN_KEY), false);
}
if (enableReturnKey && v.getText().length() == 0) {
return true;
}

//This is to prevent 'return' event from being fired twice when return key is hit. In other words, when return key is clicked,
//this callback is triggered twice (except for keys that are mapped to EditorInfo.IME_ACTION_NEXT or EditorInfo.IME_ACTION_DONE). The first check is to deal with those keys - filter out
//one of the two callbacks, and the next checks deal with 'Next' and 'Done' callbacks, respectively.
Expand All @@ -387,13 +395,7 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent keyEvent)
fireEvent(TiC.EVENT_RETURN, data);
}

boolean enableReturnKey = false;
if (proxy.hasProperty(TiC.PROPERTY_ENABLE_RETURN_KEY)) {
enableReturnKey = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_ENABLE_RETURN_KEY), false);
}
if (enableReturnKey && v.getText().length() == 0) {
return true;
}

return false;
}

Expand Down
4 changes: 4 additions & 0 deletions apidoc/Titanium/UI/TextField.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ properties:
description: |
If `true`, the return key is **disabled** when this text field is empty, and
automatically enabled as soon as the user types any text in the field.
On Android, if `true`, `return` event will not fire. Clicking on the return key will do nothing, but
the key itself won't be **disabled**.
type: Boolean
default: false
exclude-platforms: [blackberry]
Expand Down

0 comments on commit c8c9e43

Please sign in to comment.