Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19877] Android: Cannot tap to select text in TextArea with "editable" set to false like iOS

GitHub Issuen/a
TypeBug
PriorityLow
StatusReopened
ResolutionUnresolved
Affected Version/sRelease 5.0.2, Release 8.0.2
Fix Version/sn/a
ComponentsAndroid
LabelsTextArea, TextField, editable, engSchedule, parity, selectable
Reporternarender
AssigneeUnknown
Created2015-10-15T10:15:54.000+0000
Updated2019-10-28T05:14:54.000+0000

Description

*Summary:* While a TextArea object's property "editable" is set to false, end-users cannot tap to select text like how it works on iOS. This is a parity issue. Note that the TextArea is not disabled. The end-user can scroll the content. The issue is that no cursor is shown and it's impossible for the end-user to make cursor selections. (However, the setSelection() method works and text selections can be made programmatically.) *Steps to reproduce:*

Build and run the below code on Android.

Tap and hold on a word in the TextArea.

Notice that no selection was made. _(This is the issue.)_

var window = Ti.UI.createWindow();
var textArea = Ti.UI.createTextArea({
	value: "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8",
	editable: false,
	suppressReturn: false,
	left: "20dp",
	right: "20dp",
	height: "100dp",
});
window.add(textArea);
window.open();
*Note:* On iOS, if TextField property "editable" is set false, then the end-user is unable to tap to select text either. So, in this case, both Android and iOS are in parity. I think this is the "native" iOS behavior, although it is inconsistent with iOS' own TextArea behavior. *Cause:* Titanium is calling setCursorVisible(false) in the Java TiUIText.handleKeyboard() method below. [TiUIText.java#L650](https://github.com/appcelerator/titanium_mobile/blob/3b75bf2b9f9733bca93ad22d738fea0525da9431/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIText.java#L650) But since iOS' TextField does not allow text selection while "editable" is false, Android should continue to call setCursorVisible(false) only for the single-line TextField case.

Comments

  1. narender 2015-10-15

    is the bug resolved ? or any other solution to select text?
  2. narender 2015-10-19

    Is any other Alternative solution for select text in Lable/TextArea? please suggest any solution.
  3. Hieu Pham 2016-06-01

    This is because you set:
       editable: false
       
    On Android, this will disable the Text Area, and you won't be able to select anything. Behavior may be different on iOS.
  4. Pascal 2016-08-26

    "Won't Fix" ??? Can you explain why? I think 'editable' is different from 'disable'.
  5. Morten Hopstad 2016-12-07

    Not much help to get here I guess? Is there no way to be able to copy a small textarea or label?
  6. Andrew Tokmakoff 2017-06-08

    It seems this is potentially related to a known Android system issue and the SO article proposes a work-around. Perhaps that can be added to Titanium? [https://stackoverflow.com/questions/37566303/edittext-giving-error-textview-does-not-support-text-selection-selection-canc/38626276#38626276] [https://code.google.com/p/android/issues/detail?id=208169] I am encountering the same issue on 5.5.1 when I long-press on rows in a table. When I roll-back to 5.2.0, the issue goes away.
  7. Eric Merriman 2018-08-02

    Checking on this one
  8. Muhammad Qasim 2019-10-28

    Its strange that this issue is pending since 2015. There must be some solution as text based applications are useless without this feature.

JSON Source