Author Topic: How to make text in UILabel selectable (but not input)?  (Read 3305 times)

skullthug

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 37
    • View Profile
How to make text in UILabel selectable (but not input)?
« on: March 23, 2015, 04:01:01 PM »
Hi there. Thanks always for keeping NGUI healthy and running.
I'm working on a project that is implementing a simple chat system, and I was wondering if there's a simple or built-in way to make text selectable for users to Ctrl+C copy (from their chat logs).
Selecting text works fine with UIInput, but we obviously don't want users to be able to edit their chat history.

Cheers.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to make text in UILabel selectable (but not input)?
« Reply #1 on: March 24, 2015, 10:35:53 AM »
CTRL+C / CTRL+V functionality is already built into the UIInput, but if I understand correctly you're asking about a label? There is no selecting a label. You have two alternatives. Simply react to a user click on the label and set NGUITools.clipboard, or use the UIInput but set its validation to a custom function that will reset the text every time the user tries to type.

skullthug

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 37
    • View Profile
Re: How to make text in UILabel selectable (but not input)?
« Reply #2 on: March 24, 2015, 12:53:25 PM »
OK. I suspected as much. Thanks for replying.