Briwser widget: open link in application

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
hopkins
Posts: 40
Joined: Wed Nov 28, 2018 11:09 am

Briwser widget: open link in application

Post by hopkins » Sun Jul 21, 2019 1:25 pm

I am using livecode to display markdown files that are retrieved from another application ( Logitech Media Server) in html format. I chose to display them using a browser widget. The markdown files contain links. When a link is clicked in the browser widget, is it possible to open the link in a local browser application instead of navigating to the linked web page within the widget?

Thanks

bogs
Posts: 4615
Joined: Sat Feb 25, 2017 10:45 pm

Re: Briwser widget: open link in application

Post by bogs » Sun Jul 21, 2019 1:56 pm

It should be, in the dictionary, I believe the term your looking for is "linkClicked"

Code: Select all

on linkClicked pLink -- open the URL stored with the clicked text
	launch url pLink
end linkClicked
Image

hopkins
Posts: 40
Joined: Wed Nov 28, 2018 11:09 am

Re: Briwser widget: open link in application

Post by hopkins » Sun Jul 21, 2019 2:13 pm

Not sure linkclicked works with a browser widget, but will try.

bogs
Posts: 4615
Joined: Sat Feb 25, 2017 10:45 pm

Re: Briwser widget: open link in application

Post by bogs » Sun Jul 21, 2019 2:34 pm

I'm not sure either, but hopefully someone that actually works with the browser widget a lot (*cough* Hermann *cough*) will chime in and tell us for sure :wink:
Image

hopkins
Posts: 40
Joined: Wed Nov 28, 2018 11:09 am

Re: Briwser widget: open link in application

Post by hopkins » Sun Jul 21, 2019 4:34 pm

linkClicked does not work. A solution would be to store the initial URL of the widget in another property of the widget, then use the "browserNavigateBegin" message to replace the original url in the widget and launch the new url in an app. Something like this ?

Code: Select all

on browserNavigateBegin pURL

if pURL is not the originalURL of me then
	launch url pURL
	set the url of me to the originalURL of me  
end if


It would have been nicer to have an additional message to capture navigation and decide on the action.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Briwser widget: open link in application

Post by [-hh] » Mon Jul 22, 2019 12:50 am

As you have full control over your markdown/htmltext you could simply rewrite your links in the form

Code: Select all

<a onclick="liveCode.xLaunch('http://hyperhh.de')" href="">hyperhh</a>
Then set the javascriptHandlers of your widget to "xLaunch"
and script the widget (or the card) with

Code: Select all

on xLaunch u
  launch url (u)
end xLaunch
shiftLock happens

hopkins
Posts: 40
Joined: Wed Nov 28, 2018 11:09 am

Re: Briwser widget: open link in application

Post by hopkins » Mon Jul 22, 2019 10:14 am

Thanks. The solution i mentioned above works, though it is not very "elegant". I rather keep the markdown files simple to edit.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”