How to make the hyper links clicable in rich Text field

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

How to make the hyper links clicable in rich Text field

Post by pkmittal » Fri Feb 22, 2008 12:52 pm

Hello,

I have a few paragraphs in word document. Those paragraphs have couple of urls with rich text.

I copied those paragraphs in a rich text field but then the urls are not clickbale. Any idea how those urls can become clickable?

Another question is: I have a paragraph which contains a table and one image? How can I show that rich text pargaph with images and table in rev?? I have seen that when we copy that paragraph to rich text field then table and image do not get copied. Any idea what can be done to solve this issue?

thanks for your help
Best Regards
Pradeep

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Fri Feb 22, 2008 1:28 pm

Hi Pradeep,

You cannot use tables inside a text field - images should work, as long as they're not inside a table, though.

If you want URL's to work, you'll need to set the 'lockText' property of the field to false (otherwise no events are triggered) and you'll have to handle the 'linkClicked' event.
Set the script of your field to something like:

Code: Select all

on linkClicked theLink
  launch URL theLink
end linkClicked
Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

Post by pkmittal » Fri Feb 22, 2008 1:44 pm

Thanks Jan.

When I try the things, that after clicking on the link nothing happens.

It seems that when I past the hyperlink to rich text fields, it seems to get converted as as an underline text not the hyperlinks.

Any idea?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Feb 22, 2008 3:03 pm

Hi Pradeep,

I think Jan meant:

Code: Select all

on linkClicked theLink
  revGoUrl URL theLink
end linkClicked
You might want to use an if-statement to check that theLink contains a valid URL.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

Post by pkmittal » Fri Feb 22, 2008 3:59 pm

Marc,

Yes I used revGoURL but link handler does not get triggerd. I have removed the loctext of field. ( put that link handler code in the script of the field)

It does not look like like also

any idea?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Feb 22, 2008 4:06 pm

Hi Pradeep,

It looks like Revolution doesn't recognise the links and RTF doesn't have a "linked" or "grouped" style. The link you are copying is entered into the field as coloured, underlined text. Probably, you need to parse the text to recognise all links in it and set the textStyle of a text chunk to link if it appears to be a link. Sorry.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

How to Get Link Value using clickChunk

Post by pkmittal » Wed Feb 27, 2008 6:31 am

Hey mark, thanks for your reply.

since the content will be genereated dynamically in the field and it will have many different hyperlinks. So I am not sure for which dynamic text I should set the textStyle to link.

I thought of using clickChunk (put the value of the clickChunk) But since the url is sepereated by puncutation so it does not give complete text.

for example if the url contains www.google.com then using clickChunk I recieve only www or . or google etc. Is there any way to ignore puncutation so that the clickchunk can give me complete url address ??

thanks for your insights.

pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

Problem with LinkClicked Handler

Post by pkmittal » Wed Jun 11, 2008 8:06 am

Hello ,

When I am trying the following code, it does not seeems to work

Code: Select all

on linkClicked theLink
  revGoUrl URL theLink
end linkClicked
I am adding this code in the Text Field script, I have locked the field and also have locked the test but linkClicked function does not seems to be triggered.

Please let me know if you have any idea.


Thanks
Pradeep

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Jun 11, 2008 9:46 am

Hi Pradeep,

The correct command is

revGoUrl <url>

Have a look at the examples in the docs.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

Post by pkmittal » Wed Jun 11, 2008 10:06 am

Thanks Mark,

I corrected the command. but the problem is , it does not come to that handler itself.

I have a text filed. Inside that I have some text. Here is an HTML text of that field

Code: Select all

<p><a name="http://www.google.com/">www.google.com</a></p>
But when I click on the link in the text field that it does not seems to recognize it as a link and neither goes to the handler below which is defined in the text Field.

Code: Select all

on linkClicked theLink 
    answer "Hello"
    revGoURL "http://www.google.com"
    revGoURL theLink
end linkClicked
The field is locked and also the text have been locked. I tried different combinations but it does not work.

Any Insights or sample stack where I can see it working?

Thanks
Best Regards
Pradeep

Tim
Posts: 29
Joined: Wed Oct 31, 2007 12:56 pm

Post by Tim » Wed Jun 11, 2008 10:55 am

Hi there,

I've just been playing around with this and found the following will work and get you started :

1. Create a new stack
2. Put a field on the stack
3. Enter some text into the field (for example "visit google")
4. Set the lockText of the field to true
5. Add the following handler to the fields script

on linkClicked theText
if theText is not empty then revGoURL theText
end linkClicked

6. In the message box issue the following 2 commands

set the linkText of line 1 of field 1 to "www.google.com"
set the textStyle of line 1 of field 1 to link

Now when you click the link, you will be taken to google.com

Hope this gives you a working base to start from :-)

Regards,

Tim.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Jun 11, 2008 12:10 pm

Pradeep,

"name" has to be "href"

Where did you get your htmlCode?!

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

Post by pkmittal » Wed Jun 11, 2008 12:20 pm

I am not creating this html code.

When I say, put the html of field "xyz" then it gives me that html format

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Jun 11, 2008 12:23 pm

Dear Pradeep,

How did you create/set/magically produce the text?

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

Post by pkmittal » Wed Jun 11, 2008 12:28 pm

To create the text in the text field,

I just typed the www.google.com in the content section of text field.

And then I set the Link Text of field like this

Code: Select all

set the linkText of line 1 of field "test" to "http://www.google.com/"

And to know what It has set , I used,

Code: Select all

put the htmltext of field "test"
I hope this is the information you are asking for.

Post Reply

Return to “Talking LiveCode”