Curl Global Community
User Interface Basics1:Linking to Content - Printable Version

+- Curl Global Community (https://communities.curl.com)
+-- Forum: Tutorials (https://communities.curl.com/forumdisplay.php?fid=3)
+--- Forum: Public Training (https://communities.curl.com/forumdisplay.php?fid=4)
+---- Forum: Curl Clues (https://communities.curl.com/forumdisplay.php?fid=5)
+---- Thread: User Interface Basics1:Linking to Content (/showthread.php?tid=9)



User Interface Basics1:Linking to Content - kino - 06-15-2011

It's common to link to other information sources from a Curl applet. Once a user selects the link, the selected page can be displayed in the current browser window, a new empty window, or a predefined window. The displayed information can be Curl content that results from launching another Curl applet, or content defined in any other format recognized by the browser, such as HTML.


Linking to Web Pages
Adding a hyperlink to a document is done using the link text procedure with the following keyword arguments.


The simplest case only specifies the href, in which case the destination of the link will display in the current browser window.

Code:
{curl 6.0, 7.0 applet}
{applet {compiler-directives careful? = true}}

Just {link href={url "http://www.curl.com"}, click me}
to go to the Curl Web site.

In the next example, we are adding the target="_blank" property. This will open the link in a new browser window. Other properties control the tooltip, cursor style, and color.

Code:
{curl 6.0, 7.0 applet}
{applet {compiler-directives careful? = true}}

{paragraph
Try
{link
href = {url "http://www.curl.com/"},
target= "_blank",
cursor = cursor-help,
tooltip = {Tooltip "Welcome to Curl's Home Page!"},
{text color = "orange", this fancy link}
}
also. Check out its tooltip and cursor.
}


This implementation is similar to HTML, where you would have the following code:

Code:
Click me


Linking to Curl Content
A link to a Curl applet can include an anchor, or destination, specification introduced by a # character. In this case, when the user selects the link, the Curl applet will launch and it will be directed to a specific location in the file, so the selected applet is loaded in a browser and scrolled to a particular point in the applet.

The applet and the destination location are specified by:
Code:
{url link-applet.curl#introduction}


The link-applet.curl file must designate that location as a destination, using the destination text format. In our case, we are adding the following line to the file:

Code:
{destination name = introduction, {bold color = blue, Introduction to Curl}}

In our example, the code in the file would resemble the following:

Code:
{paragraph
font-size = 14pt,

{destination name = company, {bold color = blue, Curl Background}}

Founded in 1998, Curl is headquartered in Cambridge, Massachusetts
and is a wholly owned subsidiary of Sumisho Computer Systems. Curl has
over 300 customers and 40 partners worldwide.
Curl develops and maintains the Curl Rich Internet Application (RIA) platform.
The foundational technologies underlying Curl emerged out of research conducted
at the Massachusetts Institute of Technology, and the company's first product was released in 2002.

Using Curl, developers can implement a new class of complex, business-critical,
Web-based applications that cannot easily be developed with other smart client technologies.

Curl allows organizations with legacy client-server applications to
move to Web-based delivery, increasing reach and reducing cost.

{destination name = introduction, {bold color = blue, Introduction to Curl}}

With the Curl Rich Internet Application Platform, organizations can easily migrate
critical client-server applications to the web without sacrificing highly-interactive complex functionality.
Traditional Web-based Development

Many companies have been left behind by the Web revolution and are still relying on legacy
client-server applications to run critical parts of their businesses.
}

Note that we can use the destination text procedure multiple times in the file, with each location specifying a different destination name.


Adding Links as Actions
The previous examples use the link text procedure, whose associated text is rendered in an underlined style similar to standard Web conventions for links. You can also create a button that when selected automatically goes to a specified Url. This next example shows how to do this using the browse-url procedure. (Note that the creation of a CommandButton is discussed in a subsequent Curl Cue.)
Code:
{curl 6.0, 7.0 applet}
{applet {compiler-directives careful? = true}}


{CommandButton
label = "Select Me",
{on Action do
{browse-url {url "link-applet.curl#introduction"}, target = "_blank"}
}
}

Tip: Note that link and browse-url each have two arguments: href and target. A link renders as text that is underlined for the user to click on, while browse-url is used as a function that can be called in any graphical object's event handler.



For more information regarding links, please refer to the following section in the Curl Documentation:Curl Developer's Guide > Text Formatting > Special Text Formats > link and destination