Page 1 of 1
Briwser widget: open link in application
Posted: Sun Jul 21, 2019 1:25 pm
by hopkins
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
Re: Briwser widget: open link in application
Posted: Sun Jul 21, 2019 1:56 pm
by bogs
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
Re: Briwser widget: open link in application
Posted: Sun Jul 21, 2019 2:13 pm
by hopkins
Not sure linkclicked works with a browser widget, but will try.
Re: Briwser widget: open link in application
Posted: Sun Jul 21, 2019 2:34 pm
by bogs
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
Re: Briwser widget: open link in application
Posted: Sun Jul 21, 2019 4:34 pm
by hopkins
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.
Re: Briwser widget: open link in application
Posted: Mon Jul 22, 2019 12:50 am
by [-hh]
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
Re: Briwser widget: open link in application
Posted: Mon Jul 22, 2019 10:14 am
by hopkins
Thanks. The solution i mentioned above works, though it is not very "elegant". I rather keep the markdown files simple to edit.