Clickable Link within TextArea

As the title says, Is there anyway to make web links clickable in the TextArea?

I have a lot of text in my TextArea and web address’s throughout, is there any way to allow the user to click on the website and have their browser open said website?

Many thanks!

when the mouse is over the text area, scan the text below the cursor to get its start (http) and end (space), then if the user click, take the url and…

Ask if this explanation is not enough.

1 Like

Hi Emile,

I’m not too sure where to start with this. I’m still very new to Xojo and programming, could you possibly give me more information?

Thank you.

In the Language Reference, check TextArea: the Events.

Add MouseMove (I think),
In the Event, you will see the default parameters.

Go to the docs (link far above), and download the pdf. Read it, follow the examples (provided with the pdf), to learn a bit more. I cannot write a tutorial here.

Go back to this forum if you have troubles.

Introduction to Xojo Programming Book:
http://www.xojo.com/learn

Thank you Emile, I’ll start looking into it and get back to you if i can’t get it to work.

Dont waste your time with that, there is no easy way to do it in a text area with xojo. If you don’t need that the user type, you can try with the HTMLviewer, you can catch the clicked links in the CancelLoad event

I’ve done it (and I colored it - blue - and I underlined it…) years go.

Worked like a charm.

I once hacked together something using styleruns. Each stylerun corresponded to an index into an array of variants; the first stylerun corresponding to array(0), second stylerun to array(1), etc. In MouseMove I used CharPosAt and StyleRunRange to figure out which stylerun the mouse was over, and from there I could determine whether the stylerun was a link (non-link runs had Nil at their index in the array). It bogged down on longer texts but for a few KB it was fine.

Edit to add: I extracted the class and cleaned it up a bit. https://www.boredomsoft.org/hosted/HREFArea.xojo_binary_project

Hey Andrew, the link doesn’t work unfortunately.

Thank you @Ivan_Tellez will also have a look at the HTML Viewer.

The download was fine here.

My Browser was blocking it, got it downloaded!

That’s exactly what I needed. Thank you all!

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.