# Read only TextEditor should not have caret

**URL:** <https://forum.juce.com/t/read-only-texteditor-should-not-have-caret/12731>\
**Category:** General JUCE discussion\
**Created:** [April 21, 2014, 8:05pm UTC](https://forum.juce.com/t/read-only-texteditor-should-not-have-caret/12731 "2014-04-21T20:05:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lalala](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lalala/32/8577_2.png) [@lalala](https://forum.juce.com/u/lalala)\
**Post date:** [April 21, 2014, 8:05pm UTC](https://forum.juce.com/t/read-only-texteditor-should-not-have-caret/12731/1 "2014-04-21T20:05:23Z")

</div>

What would you think about always hiding the caret when a textEditor is readOnly?  
I find it really confusing to see a blinking caret, as it gives the feeling that we can type text in it.  
the 'load file browser' FileChooser of the dialogs demo is a good example of that..  
&nbsp;

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 21, 2014, 8:12pm UTC](https://forum.juce.com/t/read-only-texteditor-should-not-have-caret/12731/2 "2014-04-21T20:12:59Z")

</div>

Just call setCaretVisible (false) if you don't want one.

I'm sure there are people who'd need to make it visible, so I don't think it'd make sense to disallow this.

---

<div class="post-metadata">

**Author:** ![lalala](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lalala/32/8577_2.png) [@lalala](https://forum.juce.com/u/lalala)\
**Post date:** [April 21, 2014, 8:50pm UTC](https://forum.juce.com/t/read-only-texteditor-should-not-have-caret/12731/3 "2014-04-21T20:50:24Z")

</div>

ok, fair enough. but appart from that default behaviour, note that&nbsp;setCaretVisible (true) tests if the editor is read only, and&nbsp;make the caret visible only if it is not read only :)

&nbsp;

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 22, 2014, 10:03am UTC](https://forum.juce.com/t/read-only-texteditor-should-not-have-caret/12731/4 "2014-04-22T10:03:40Z")

</div>

Ah, yes, that's a bit inconsistent! Ok, thanks for letting me know, I'll maybe sanity-check it when I get a moment.

---

<div class="post-metadata">

**Author:** ![rebbur](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rebbur](https://forum.juce.com/u/rebbur)\
**Post date:** [April 23, 2014, 6:24am UTC](https://forum.juce.com/t/read-only-texteditor-should-not-have-caret/12731/5 "2014-04-23T06:24:14Z")

</div>

Often you would want to allow a user to select and copy the readonly text. So always hiding the caret is not a solution.

---

<div class="post-metadata">

**Author:** ![Tortyfoo](https://avatars.discourse-cdn.com/v4/letter/t/5e9695/32.png) [@Tortyfoo](https://forum.juce.com/u/Tortyfoo)\
**Post date:** [April 23, 2014, 7:10am UTC](https://forum.juce.com/t/read-only-texteditor-should-not-have-caret/12731/6 "2014-04-23T07:10:09Z")

</div>

I actually use TextEditor in read-only mode and don't want to allow the user to be able select text or display a pop-up menu. Had hidden caret as above and disabled PopupMenu with setPopupMenuEnabled (false); but can't see an easy way to disable selection. Separate issue is on Android it will auto display the keyboard which as it is read-only would prefer it didn't.

---

<div class="post-metadata">

**Author:** ![lalala](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lalala/32/8577_2.png) [@lalala](https://forum.juce.com/u/lalala)\
**Post date:** [April 23, 2014, 7:45am UTC](https://forum.juce.com/t/read-only-texteditor-should-not-have-caret/12731/7 "2014-04-23T07:45:08Z")

</div>

Well, I think that selection should be allowed and well supported even if the carret is not shown. Like if you select this forum&nbsp;text in your web-browser, it will work fine, and no carret is shown.
