URL in a stirng

Does it possible for an URL in a string? I know msgbox is not an option. If I really want to have a url embeded into a string, what I can do?

For example, it’s quite common in a “About” window to have the website link in a detailed description text. User can click the URL to open an default web browser to view the website. How can I do that?

In VB.NET the RichTextBox has an option to choose URL detectable or not, dose xojo has the similar function or not? Thanks!

Bo,

Did this not answer your same question in your previous post?

https://forum.xojo.com/11032-put-an-url-hyperlink-in-msgbox/p1#p79593

[quote=79838:@Mike Cotrone]Bo,

Did this not answer your same question in your previous post?

https://forum.xojo.com/11032-put-an-url-hyperlink-in-msgbox/p1#p79593[/quote]

Thank you for your remind. Not really, because after I found the RichTextBox in VB.NET can have links in the text, I wonder if Xojo can do that too or not. I don’t know how to upload a screenshot. A button solution does work, but I want to dig more deeper.

There is nothing built in to Xojo to accomplish a control to recognize a URL. You have to build it.

Ie. I built this using the following in one of my other apps.

  1. Used Canvas
  2. Used DrawString to draw my “URL text”
  3. used Mouse Move to change my icon to show that there is a valid link when moved over the URL Text
  4. Used Mouse Up to execute the HTTP command in my last post

The same approach could be used for almost any control that has those events (text area, textfield, listbox, etc)

HTH.

[quote=79854:@Mike Cotrone]There is nothing built in to Xojo to accomplish a control to recognize a URL. You have to build it.

Ie. I built this using the following in one of my other apps.

  1. Used Canvas
  2. Used DrawString to draw my “URL text”
  3. used Mouse Move to change my icon to show that there is a valid link when moved over the URL Text
  4. Used Mouse Up to execute the HTTP command in my last post

The same approach could be used for almost any control that has those events (text area, textfield, listbox, etc)

HTH.[/quote]
Good to know. Thanks, Mike!

[quote=79832:@BO CHEN]Does it possible for an URL in a string? I know msgbox is not an option. If I really want to have a url embeded into a string, what I can do?

For example, it’s quite common in a “About” window to have the website link in a detailed description text. User can click the URL to open an default web browser to view the website. How can I do that?

In VB.NET the RichTextBox has an option to choose URL detectable or not, dose xojo has the similar function or not? [/quote]

Here is code you place in a textArea SelChange event :

Sub SelChange()
dim character, zurl as string
dim position as integer = Me.SelStart
dim beginning, ending as integer

while character<>" " and character <> EndOfLine and character <> chr(13) and position >Me.SelStart-150 _
and position >1
character = Mid(Me.Text,position,1)
position = position-1
wend
beginning = position+2
position = Me.SelStart
character = “”

while (character<>" ") and character <> EndOfLine and character <> chr(13) and position < Me.SelStart+150 _
and position <len(Me.Text)
character = Mid(Me.Text,position,1)
position = position+1
wend
ending = position-1

zurl = Mid(Me.text,beginning,ending-beginning)
msgbox zurl

'other types of url can be added if needed
if left(zurl,7) = “http://” or left(zurl,8) = “https://” or left(zurl,7) = “mailto:” then
ShowURL(zurl)
end if
End Sub

You can create a TextArea class with this event added, and all your TextAreas will have URL detection :slight_smile: