-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-25671]Android : TextField's some returnKeyType values not firing 'return' event #9933
Conversation
Add return event property for distinguishing the origin of the event.
Generated by 🚫 dangerJS |
@ypbnv, I tested the "return" event handling on iOS with TextFields and TextAreas. The "return" event is always fired when the key is pressed. It is also fired in a TextAreas where the return key inserts a newline. I've tried with |
@@ -52,6 +52,9 @@ | |||
import android.widget.TextView; | |||
import android.widget.TextView.OnEditorActionListener; | |||
|
|||
import static ti.modules.titanium.ui.UIModule.RETURN_KEY_TYPE_ACTION; | |||
import static ti.modules.titanium.ui.UIModule.RETURN_KEY_TYPE_CARTRIDGE_RETURN; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of indicating the return type. Especially on iOS since TextAreas can fire a "return" event when its an action or newline, depending on the TextArea.suppressReturn property setting. But I don't think we should add this feature in a patch release. We should talk to @hansemannn about it. Ideally, we should add such a feature on both Android and iOS at the same time.
Also, I think you mean "carriage return", not "cartridge return". :)
The comments below need to be correct for this as well.
And perhaps calling the return key type "NEWLINE" instead of "CARRIAGE_RETURN" would be better as well. Especially since Android and iOS technically add a \n
character, not a \r
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, "carriage". I guess I carrieged away typing it wrong...
If we rename the constant we can get replace it with "new line" everywhere.
Also, yes, I did not think about a patch release being inappropriate for new additions. Would a minor be fine if we push it together with iOS? For now I will comment the additional key in the dictionary. We can have a separate ticket for that if we are doing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is new "features" and APIs should not go into patch releases. So, if we're adding a new API, it's a new feature. And ideally, new APIs should be discussed with Hans (iOS) and Kota (Windows) in advance for their feedback and so they can schedule it to be implemented in the future.
That said, we do allow "enhancements" in a patch release from time to time. That's a gray-area for us. But typically its a change in behavior for an existing API (assuming it's not a breaking change). Any enhancements we want to add to a patch release needs to be a team decision beyond you and I.
// And because of that we skip the firing of a RETURN event from this call in favor of the | ||
// one from onTextChanged. The event carries a property to determine whether it was fired | ||
// from the IME_ACTION button or the cartridge return one. | ||
if (tv.getMaxLines() == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking if getMaxLines()
is 1, we should use the field
member variable instead. It'll be set to true
for TextFields.
Note that upcoming PR #9927 will make max-lines settable and I don't want you to get burned by this.
@ypbnv, do you have a bluetooth keyboard you can test with on your Android phone? We may want to double check the handling of the return key from the keyboard as well. |
Rename constant. Change the check for UIText being a field or area.
@jquick-axway Yes, I can get my hands on a bluetooth keyboard to check if everything is fine. |
@jquick-axway Tried a bluetooth keyboard with a tablet (Samsung Galaxy Tab S) and a phone (Samsung S8). Both in landscape and portrait. Hitting the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more minor edit. Everything else is fine. Thanks!
apidoc/Titanium/UI/TextField.yml
Outdated
description: | | ||
Since in Landscape mode Android provides both the New Line and the Action type | ||
buttons as return keys the 'button' property in the event is used to distinguish from | ||
which key has the event been fired. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get rid of this description since we're not offering this new property yet.
FR Passed.
Studio Ver: 5.1.0 |
Waiting for CR to pass. |
JIRA: https://jira.appcelerator.org/browse/TIMOB-25671
Description:
Always trigger the return key event from software keyboard.
In Landscape mode for phones Android provides both the return key for New Line and an Action key with the desired IME_ACTION mode. I extended the return event with a property that distinguishes from which key the return event has been fired.
Names of constants and name of the property I have added can be changed.
Note: This relies on user interaction with the software keyboard, so I don't think we can have unit tests for the code.
Test case:
app.js