Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: ankit khetrapal on January 27, 2014, 02:24:14 AM

Title: Make Links in string clickable
Post by: ankit khetrapal on January 27, 2014, 02:24:14 AM
Hi NGUI Team,

Is there any way i can make links in a particular string(applied on a UILabel as text) clickable(basically when the user clicks on that area of the label we open that particular link in a new tab).

I can easily strip the links using RegEx and then apply different color codes to them but the issue is my label has multiple lines and i cannot split the normal texts and links in different labels as it would lead to inappropriate collider position triggering the action.

Eg Here is the label

i am using ngui http://www.tasharen.com/?page_id=140 try
this great tool. here is the
forum http://www.tasharen.com/forum/index.php

Now can i have colliders on the specific areas where there is a link and then trigger the event to open that link in a new tab from there.
Title: Re: Make Links in string clickable
Post by: Wahooney on January 27, 2014, 04:01:54 AM
A better system would be defining an event of some sort, so your text could be something along the lines of:

"Hello, [event=ClinkLink,http://www.etc.com/] click here [-] to open a new window."

This would invoke the ClickLink function in a component, with the string argument "http://www.etc.com/". This system would allow you to do just about anything when certain characters / words / whatever are clicked, instead of just opening a link to a website.

Some thought would have to go into the rendering of the label:
How are they coloured?
Must they be coloured with [#ffffff]?
Are links coloured automatically?
Is there a universal link colour?
Is it per label?
etc.
Title: Re: Make Links in string clickable
Post by: ankit khetrapal on January 27, 2014, 04:25:23 AM
Hi Wahooney,

Yes what you are suggesting is fine here, i agree with you but my question here is how to implement this.

And for the different colors on the label, its pretty simple to implement, check the link below
http://www.tasharen.com/?page_id=166
Title: Re: Make Links in string clickable
Post by: Wahooney on February 04, 2014, 03:49:32 AM
Ah! Misunderstanding. Moving on ;)

Apparently it's coming to NGUI in the next few weeks, there is a post somewhere around these forums where AaronMook says as much.
Title: Re: Make Links in string clickable
Post by: fedorenkosergiy on September 05, 2016, 07:25:00 AM
You can write BBCode like this:

  1. [url="http://example.com"][u]example[/u][/url]
  2.  

Then add collider to your UILabel component.

Finaly you have to add OpenURLOnClick component from NGUI Examples folder to object with target UILabel.

And don't forget turn on BBCode flag.