WebMenuItem.Tag

From Xojo Documentation

Revision as of 13:48, 14 August 2017 by PLefebvre (talk | contribs)

Property (As Variant )
aWebMenuItem.Tag = newVariantValue
or
VariantValue = aWebMenuItem.Tag

New in 2011r2

Supported for all project types and targets.

A hidden value associated with the menu item.

Notes

The tag is accessible via code when the user chooses the menu item but, unlike the Text property, is not displayed in the menu. It works like the RowTag property of a PopupMenu control.

The Tag is a variant so it can contain any value, including class references.

Example

This code displays a menu when you right-click on a Label. This code is in the Shown event handler of a WebLabel:

Dim file As New WebFile
file.MimeType = "text/plain"
file.ForceDownload = True // If False, the browser may try to display the file instead of download it
file.FileName = "TextFile.txt"
file.Data = "Hello, world!"

Dim base As New WebMenuItem

Dim downloadMenu As New WebMenuItem("Download")
downloadMenu.Tag = file // The file to download
base.Append(downloadMenu)

Me.ContextualMenu = base


In the ContextualMenuAction event handler of the WebLabel, you can then use the tag to download the previously created file:

If Item.Text = "Download" Then
Dim file As WebFile = Item.Tag
ShowURL(file.URL)
End If