KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to set a hyperlink to a text or picture for 4D write pro
PRODUCT: 4D Write Pro | VERSION: 16 R4 | PLATFORM: Mac & Win
Published On: November 22, 2017

4D V16R4 introduces a new attribute for setting a selected range of data (text, picture or both) into a hyperlink and getting the target URL from the selected hyperlink in a 4D Write Pro document. The new attribute can be used through the command WP SET ATTRIBUTES and WP GET ATTRIBUTES.

The example below shows how to set a hyperlink for a selected text:

C_TEXT($url)
$url:="www.4d.com"
$range:=WP get selection(*;"WriteProArea")
WP SET ATTRIBUTES($range;wk link url;$url)

For example, to set a hyperlink for a text use the code above in an object method of a button as shown in the pictures below then highlight a text in the 4D write pro erea:



Then click the set link button :



Here is an example on how to retrieve the URL from the selected hyperlink using the WP get selection commands:

$range:=WP get selection(*;"WriteProArea")
WP GET ATTRIBUTES($range;;wk link url;geturl)

The WP GET ATTRIBUTES will get the url that was set using WP SET ATTRIBUTES