Hyperlinking Screens

Hyperlinking in Canvas allows you to open another Canvas screen from the screen you are currently viewing.

Hyperlinking Via Controls

A limited set of Canvas controls support a non-scripted method to hyperlink to other screens using the same hyperlink modes described below.

Hyperlinking Via Script

Scripting is not supported by TWC

Hyperlinking is accomplished via script using the Hyperlink method on the sending (hyperlinking) screen and the OpenedViaHyperlink event on the receiving (hyperlinked) screen. Hyperlinking is supported between screens, objects, and Nested Views in Canvas, Canvas.View, and Canvas.View.Lite. The Hyperlink method supports several modes:

Optionally, you can pass a siteService, facility ID, or a data object to a hyperlinked screen.

Hyperlink Method

The Hyperlink method is included on the Screen object. Scripting is not supported by TWC

Syntax

Objects.Screen.Hyperlink(path, source, mode);

Parameters

There are several parameters that can be passed in via the Hyperlink method:

Parameters Description

path

The path to the file to open. This parameter is required.

Linking between Canvas screens, objects, and Nested Views is quite flexible. You don't need to specify the service or folder information in the path to find related screens, objects, or Nested Views, although you can if desired. When specifying a path to another file, the following notes apply:

If the screen or object file is in an APPS or BSS folder, you can specify the:

  • full path of the file
  • folder\filename.can of the file (Canvas uses the source file's service)
  • filename.can of the file (Canvas uses source file's service and folder)

Not supported by TWC If the screen or object file is in the local file system, you can specify the:

  • full path of the file
  • filename.can of the file (Canvas uses source file's path)

source

The source of the file to open. This parameter is optional. Options include:

  • BSS — Indicates that the file is stored in an APPS or BSS folder
  • Local — Indicates that the file is stored in a local or network file-system folder. Not supported by TWC

mode

The optional mode of hyperlinking. There are several modes and the behavior differs depending on the application initiating the hyperlink:

  Behavior
Hyperlink Method Mode Canvas Nested View Canvas.View Canvas.View.Lite

Open

Opens a new window (with a toolbar) with the provided screen.

Opens a new window with the provided screen.

Open a new window with the provided screen.

Open a new window with the provided screen.

Modal Open

Opens a modal popup window (with a toolbar) with the provided screen. The popup has primary focus; all other windows are locked until the popup is dismissed.

Opens a modal popup window with the provided screen. The popup has primary focus; all other windows are locked until the popup is dismissed.

Opens a modal popup window with the provided screen. The popup has primary focus; all other windows are locked until the popup is dismissed.

Opens a modal popup window with the provided screen. The popup has primary focus; all other windows are locked until the popup is dismissed.

OpenAndClose

Opens a new window and close the window that initiated the hyperlink.

Opens a new window with the provided screen and closed the screen that contains the Nested View.

If initiated from the main screen of Canvas.View.Lite, behave the same as Open.

Opens a new window and close the screen that initiated the hyperlink.

If initiated from the main screen, behaves the same as Open.

If initiated from a window opened via a hyperlink, opens a new window and close the window that initiated the hyperlink.

Replace

Replaces the contents of the initiating screen’s window with the new screen.

Replaces the contents of the Nested View with the new screen.

Replaces the contents of the initiating screen’s pane with the new screen.

If initiated from the main screen, replaces the main screen with the new screen.

If initiated from a window opened via a hyperlink, replaces the window's screen with the new screen.

ReplaceWithNavigation

Behaves the same as Replace, but also adds a navigation toolbar to the top of the window.

Behaves the same as Replace, but also adds a navigation toolbar to the top of the Nested View.

Behaves the same as Replace, but also adds a navigation toolbar to the top of the pane.

If initiated from the main screen, behaves the same as Replace, but also adds a navigation toolbar to the top of the main screen.

If initiated from a window opened via a hyperlink, behaves the same as Replace, but also adds a navigation toolbar to the top of the window.

Close

Closes the window that initiated the hyperlink.

Closes the window that initiated the hyperlink.

Closes the screen that contains the Nested View.

If initiated from the main screen of Canvas.View, there is no change and the screen remains open.

If initiated from a window opened via a hyperlink from Canvas.View, closes the window that initiated the hyperlink.

If initiated from the main screen of Canvas.View.Lite, there is no change and the screen remains open.

If initiated from a window opened via a hyperlink from Canvas.View.Lite, closes the window that initiated the hyperlink.

siteService

An optional string parameter that can be used to pass content to a hyperlinked screen. Used to pass a siteService to override the hyperlinked screen's siteService with a passed value.

facilityID

An optional string parameter that can be used to pass content to a hyperlinked screen. Used to pass a facility ID to override the hyperlinked screen's facility ID with a passed value.

data

An optional string parameter that can be used to pass content to a hyperlinked screen. Used to pass in an object to the hyperlinked screen, for example, a DateTime object, but it can be anything you want to send. This parameter is of type object, but is actually called data.

Hyperlinking Modes Example

The following example code shows the four hyperlink modes applied to four buttons on a screen. The path of the hyperlink is defined in the Objects.HyperlinkEditBox.Text:

Copy
Hyperlinking modes example
public ScreenClass()
{
    // control event handler code goes here -- do not modify
    Objects.Button4.Click += new EventHandler(this.Button4_Click);
    Objects.Button2.Click += new EventHandler(this.Button2_Click);
    Objects.Button1.Click += new EventHandler(this.Button1_Click);
    Objects.Button3.Click += new EventHandler(this.Button3_Click);
    // add your custom initialization code here
}
#region Button3
private void Button3_Click(object sender, EventArgs args)
{
    Objects.Screen.Hyperlink(Objects.HyperlinkEditBox.Text, CanvasFileSource.Local, HyperlinkMode.Open);
}
#endregion
#region Button1
private void Button1_Click(object sender, EventArgs args)
{
    Objects.Screen.Hyperlink(Objects.HyperlinkEditBox.Text, CanvasFileSource.Local, HyperlinkMode.OpenAndClose);
}
#endregion
#region Button2
private void Button2_Click(object sender, EventArgs args)
{
    Objects.Screen.Hyperlink(Objects.HyperlinkEditBox.Text, CanvasFileSource.Local, HyperlinkMode.Replace);
}
#endregion
#region Button4
private void Button4_Click(object sender, EventArgs args)
{
    Objects.Screen.Hyperlink(Objects.HyperlinkEditBox.Text, CanvasFileSource.Local, HyperlinkMode.ReplaceWithNavigation);
}
#endregion

OpenedViaHyperlink Event

The mechanism by which Canvas accesses this object is the OpenedViaHyperlink event on the hyperlinked screen, which is triggered whenever a screen is opened via a hyperlink. The screen issuing the hyperlink must also provide a value for a data parameter; without this custom data, the event will not fire.

The event requires a parameter that will contain the object that was passed into the Hyperlink method. This way the hyperlinking screen can pass generic data to the hyperlinked screen.

For example, Hyperlink_Screen_A.can can hyperlink to Hyperlink_Screen_B.can and pass in a SiteService and facility to the recipient Text Tool(s). The hyperlinked screen will load the screen, load the SiteService and facility as originally configured, then clear out the original values, and replace the screen with the overridden values from the hyperlinking screen.

Passing a SiteService or Facility Example

The following example code shows how to pass a SiteService and facility to a hyperlinked screen via a button click event:

Copy
Passing a SiteService or Facility example
public void ScreenClassInitializer()
{
    // control event handler code goes here -- do not modify
     
    Objects.Button1.Click += new EventHandler(this.Button1_Click);
    Objects.Button2.Click += new EventHandler(this.Button2_Click);
     
    // add your custom initialization code here
}
#region Button1
 
private void Button1_Click(object sender, EventArgs args)
{
    Objects.Screen.Hyperlink(@"C:\Canvas Screens\Hyperlink\Hyperlink_Screen_B.can",
    CanvasFileSource.Local,
    HyperlinkMode.Open,
    Objects.Screen.CygNetConfiguration.SiteService.SiteService,
    Objects.Screen.CygNetConfiguration.Facility.FacilityID,
    DateTime.Now);
}
 
#endregion
#region Button2
 
private void Button2_Click(object sender, EventArgs args)
{
    Objects.Screen.Hyperlink(@"C:\Canvas Screens\Hyperlink\Hyperlink_Screen_B.can",
    CanvasFileSource.Local,
    HyperlinkMode.ReplaceWithNavigation,
    Objects.Screen.CygNetConfiguration.SiteService.SiteService,
    Objects.Screen.CygNetConfiguration.Facility.FacilityID,
    DateTime.Now);
}
#endregion

Passing an Object Example

The following example code snippet shows how to pass a DateTime object to a Text Tool on a hyperlinked screen:

Copy
Passing an object example
public ScreenClass()
{
    // control event handler code goes here -- do not modify
    Objects.Screen.OpenedViaHyperlink += new EventHandler(this.Screen_OpenedViaHyperlink);
    // add your custom initialization code here
}
#region Screen
private void Screen_OpenedViaHyperlink(object sender, EventArgs args)
{
    var hyperlinkEvent = args as OpenedViaHyperlinkEventArgs;
    var date = (DateTime)hyperlinkEvent.Data;
    Objects.TextTool3.Text = date.ToString();
}
#endregion