Hyperlinks and Tips
Use hyperlinks to create content that is connected to your other documents
and to the outside world. Connect user input to different types of custom
actions to create dynamiclly generated content.
Web links
You can create a hyperlink to a web address simply by placing a
URL
inside a Span.
readonly
URL
WebAddress
=
new
(
"www.nytril.com"
);
LinkText
=
Span
{
WebAddress
;
};
www.nytril.com
Underlined on mouse-over
Change the text
If you want different text for the link, use the
Action
property to specify the link that applies to
the entire Span.
Message
=
Span
{
TextColor
:
Colors
.
Blue
;
"Visit us on the web"
;
Action
:
WebAddress
;
};
Visit us on the web
Hidden URL, underlined text on mouse-over
Popup tips
Use the
Tip
property to specify a formatted popup when the user hovers the mouse over the text
in the Span.
TheAnswer
=
Span
{
TextColor
:
Colors
.
DarkGreen
;
"The answer is "
;
Bold
42;
};
PopupMessage
=
Span
{
"The answer"
;
Tip
:
new
Tip
(
TheAnswer
)
;
};
The answer
The answer is
42
Tip + Action
Use the
TipAction
property to specify a both a tip and an action at the same time.
ActionTip
=
Span
{
"Here's a tip: "
;
Span
{
"Visit us on the web"
;
Underline
;
TipAction
:
WebAddress
;
}
};
Here's a tip:
Visit us on the web
www.nytril.com
Document Anchors
To create links within a single document, you must first give the target Paragraphs a reference
name using the
Anchor
function. The anchor name of each Paragraph must be unique in the
document.
Location1
=
"Location 1"
;
AnchoredPar
=
Paragraph
{
"Important paragraph with the \"
{0}
\" anchor. "
(
Location1
);
DocFields
.
Anchor
(
Location1
);
};
Important paragraph with the "Location 1" anchor.
Anchor Links
Once the anchor name is assigned to a paragraph, you can create an action that links to that
paragaph, no matter where it is placed in the document.
HelpLink
=
Span
{
Action
:
new
Action
(
Actions
.
ToAnchor
,
Location1
);
"Find out more in the help section. "
;
};
Find out more in the help section.
QR Codes
To label products or printed documents, QR codes can be added with the
QRBox
formatter. Notice
that there is always a white border around the QR code which is required by the QR readers.
QRCode
=
VBox
{
HAlign
:
Center
;
"Follow us online"
;
QRBox
(
WebAddress
, 1.5");
};
Follow us online
https://www.nytril.com
"Quiet zone"
QR Codes with Links
Change the level of error correction in the QR code by setting the error parameter to a number
from 0 to 3.
QRLink
=
VBox
{
HAlign
:
Center
;
Span
{
TextHeight
:
70%;
"Community Edition"
;
};
QRBox
(
WebAddress
, 1.5",
3
) {
TipAction
:
WebAddress
;
};
};
Community Edition
https://www.nytril.com
More complex pattern includes more error correction
Links to Files
Create an action to browse to a local file with the
ToFile
action type. This will bring up File
Explorer on Windows (or Finder on the Mac) and point it to the specified path.
FileLink
=
Span
{
"Open in File System"
;
Tip
:
"Browse the File"
;
Action
:
new
Action
(
Actions
.
ToFile
,
IO
.
Folders
.
Source
IO
.
FileName
(
"Hyperlinks.nytril"
));
};
Open in File System
Browse the File
Custom Actions
Create a complex custom action by inheriting the
Action
class and overriding the Execute function.
class
CustomAction
:
Action
{
var
Text
;
Constructor
(
text
) {
super
.
Constructor
(
Actions
.
Execute
);
Text
=
text
;
}
override
EventResponse
Execute
{
System
.
TextToClipboard
(
Text
);
return
EventResponses
.
MessageTip
(
"Text copied to the clipboard"
);
}
}
CustomLink
=
Span
{
Icons
.
copy
;
Space
;
"Copy Text"
;
TipAction
:
new
CustomAction
(
"Custom Text"
);
};
Copy Text
Text copied to the clipboard