OnClick - cLinkLabel
Called when a link is clicked
Type: Event
Parameters
| Parameter | Type | Description |
|---|---|---|
| iItem | Integer | Link id (zero-based) |
| sID | String | The text of the link id (can be blank) |
| sUrl | String | The URL in the link. If non-blank, it shells and opens the link. |
Syntax
Procedure OnClick Integer iItem String sID String sUrl
Description
OnClick is called when a link is clicked. It passes the clicked link's item number and depending on the whether the link is an ID or an HREF, a value in either the sID or sUrl string.
Note that the cLinkLabel class has a default behavior for OnClick, which is:
Procedure OnClick Integer iItem String sID String sUrl
If (sUrl<>"") Begin
Runprogram Shell Background sUrl
End
End_Procedure
Therefore, if your link is single or multi-item HREF, you will probably not need to augment this event, as the default behavior will shell execute the HREF (sUrl) reference.
Object oLink is a cLinkLabel
Set Size to 14 100
Set Location to 10 10
Set Label to ('<A HREF="http://www.DataAccess.com">Data Access Worldwide</A>')
End_Object
If you link reference is an ID, you will need to create an OnClick handler for this. If your link only has a single linked item, you will not need to use the parameters passed to the event.
Object oLinkAbout is a cLinkLabel
Set Size to 8 63
Set Location to 243 250
Set Label to '<A ID="LinkId">About this program</A>'
Procedure OnClick Integer iItem String sID String sUrl
Send Activate_About
End_Procedure
End_Object
If your link label contains multiple items, you will most likely use the sID or sUrl string to determine the action.
Object oLinkLabel3 is a cLinkLabel
Set Size to 8 59
Set Location to 113 232
Set Label to '<A ID="clear">Clear</A> or <A ID="save">Save</A>'
Procedure OnClick Integer iItem String sID String sUrl
If (sID="clear") Begin
Send Request_Clear
End
Else Begin
Send Request_Save
End
End_Procedure
End_Object
In the following example, a link contains an HREF and two ID items. If the HREF is clicked, you will simply forward the event. If the ID is selected, you will handle that code yourself.
Object oLinkLabel3 is a cLinkLabel
Set Size to 8 59
Set Location to 113 232
Set Label to '<A ID="clear">Clear</A>, <A ID="save">Save</A> or, if confused, <A HREF="http://www.DataAccess.com">Visit Data Access Worldwide</A>'
Procedure OnClick Integer iItem String sID String sUrl
If (sUrl<>"") Begin
Forward Send OnClick iItem sID sUrl
End
Else If (sID="clear") Begin
Send Request_Clear
End
Else Begin
Send Request_Save
End
End_Procedure
End_Object