McBasic™Get McBasic™ ↗
Build 881
Components · Nonvisual component
Menu component icon

Menu

Connect menu items to a named event handler.

4 properties1 events0 methodsDefault: Click

Use it in a Form#

A menu belongs in the component tray even though it creates a visible command surface at runtime. Configure its items before writing the event code. Keep the command identity stable so renaming a visible label does not accidentally change what the application does.

Add Menu to the component tray and name it mnuMain for this example:

PropertyExample value
Items"File\nNew\n---\nQuit"
VisibleTrue
EnabledTrue
ClickedIndex-1

A complete handler from Forms/frmMain.bas. The linked lesson includes its surrounding controls, declarations and helpers.

Forms/frmMain.bas
Private Sub mnuMain_Click()
    lblStatus.Caption = "Menu item " & CStr(mnuMain.ClickedIndex + 1) & " selected."
End Sub

Properties#

Contract defaults are shown below. Where a new control has a different Designer starting value, that value is listed separately.

Items

StringDefault: "File\nEdit\nView"

One top-level menu caption per line. A line containing '-' creates a separator; empty lines are ignored.

Visible

BooleanDefault: True

Whether this menu is shown in the running application's menu bar.

Enabled

BooleanDefault: True

Whether this menu accepts item interaction in the running application.

ClickedIndex

LongDefault: -1

Zero-based index of the last clicked menu item; separators do not receive an index and -1 means no item has been clicked.

Range: -1 to 100000.

Events and parameters#

Replace control with the object’s Name when creating a handler. ByRef arguments may be changed by your handler; ByVal arguments report an input value.

Click

Occurs once when the component is logically activated by the user.

Signature — see the complete lesson for an implementation
Private Sub control_Click()

No parameters.

Methods#

No methods are declared in this component’s built-in metadata. Use its documented properties and events; do not infer APIs from a similarly named control in another framework.

Source baseline 20f4bfed6b · Build manifest