Recent Changes - Search:

WikiDoc

Categories

The [menuRef] command

Commands.MenuRefCommand History

Hide minor edits - Show changes to markup

September 30, 2009, at 09:03 AM by bd - Removed experimental
Changed line 2 from:
This file documents the new [menuRef] command in version 8.2a1d5 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.
to:
This file documents the new [menuRef] command in version 8.2a1d5 of AlphaX.
June 10, 2008, at 01:29 PM by bd - Typo
Changed line 98 from:
 	menuItem items token
to:
 	menuRef items token
July 11, 2007, at 07:16 AM by bd - Added "contextual" token info
Changed lines 2-3 from:
This file documents the new [menuRef] command in version 8.2a1d3 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.
to:
This file documents the new [menuRef] command in version 8.2a1d5 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.

Added line 73:
Added lines 125-126:

The available options are exactly the same as with the [menuRef create] command.

Changed line 130 from:

menus can be targetted by the [menuRef] and [menuItem] commands using the

to:

menus can be targetted by the [menuRef] and [menuItem] commands using the

Changed lines 136-137 from:

These menus cannot be deleted or removed using the [menuRef delete] and [menuRef remove] commands.

to:

The application also provides a symbolic token "contextual" to designate the contextual menu which is displayed when the user control-clicks on a document window (see the ContextualModules page on this wiki).

These menus cannot be deleted or removed using the [menuRef delete] and [menuRef remove] commands.

April 30, 2007, at 01:48 PM by bd - New -updateProc option. Reorg create options.
Added line 63:
Changed lines 65-72 from:
  • the -title option lets you specify the title of the menu. The -icon and the -title options are mutually exclusive.
to:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus representing a fileset).

  • the -name option lets you change the name of the menu. This option is provided only for compatibility reasons: the previous menu syntax identified menus by name. By default, the name field of a menu created with the new syntax contains the menu token. Under some circumstances, one might want to modify the name of the menu to ensure that a menu created with the new syntax can be found by procs using the old syntax.

  • the -title option lets you specify the title of the menu. The -icon and the -title options are mutually exclusive.

  • the -updateProc option lets you specify a Tcl procedure to evaluate before a menu is opened. This can be useful when the contents of a menu has to be adjusted before it is displayed: depending on the context, one might want to enable or disable some items, add or remove items, or even rebuild the menu entirely. When the procedure declared by this option is invoked, the token of the menu is appended to its list of arguments. Note that the procedure is only invoked once per menu tracking session for a given menu, even if that menu is closed and opened multiple times by the user. In order to remove such a procedure, use the [menuRef set] command and pass an empty string for this option.
Deleted lines 123-130:

Here is the list of the available options:

  • the -attributes option lets you modify the attributes of the menu
  • the -command option lets you change the Tcl proc attached to the menu
  • the -icon option lets you modify the icon associated with a menu. Use an empty string to remove an icon.
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus representing a fileset).
  • the -name option lets you change the name of the menu. This option is provided only for compatibility reasons: the previous menu syntax identified menus by name. By default, the name field of a menu created with the new syntax contains the menu token. Under some circumstances, one might want to modify the name of the menu to ensure that a menu created with the new syntax can be found by procs using the old syntax.
  • the -title option lets you change the title of the menu.
  • the -updateProc option lets you specify a Tcl procedure to evaluate before a menu is opened. This can be useful when the contents of a menu has to be adjusted before it is displayed: depending on the context, one might want to enable or disable some items, add or remove items, or even rebuild the menu entirely. When the procedure declared by this option is invoked, the token of the menu is appended to its list of arguments. Note that the procedure is only invoked once per menu tracking session for a given menu, even if that menu is closed and opened multiple times by the user. In order to remove such a procedure, use the [menuRef set] command and pass an empty string for this option.
April 30, 2007, at 01:40 PM by bd - New -updateProc option
April 30, 2007, at 01:39 PM by bd - New -updateProc option
Added line 123:
  • the -updateProc option lets you specify a Tcl procedure to evaluate before a menu is opened. This can be useful when the contents of a menu has to be adjusted before it is displayed: depending on the context, one might want to enable or disable some items, add or remove items, or even rebuild the menu entirely. When the procedure declared by this option is invoked, the token of the menu is appended to its list of arguments. Note that the procedure is only invoked once per menu tracking session for a given menu, even if that menu is closed and opened multiple times by the user. In order to remove such a procedure, use the [menuRef set] command and pass an empty string for this option.
March 19, 2007, at 02:19 PM by bd - New [menuRef clear] subcommand
Changed lines 120-121 from:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus

representing a fileset).

to:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus representing a fileset).
March 19, 2007, at 02:17 PM by bd - New [menuRef clear] subcommand
Changed line 3 from:
This file documents the new [menuRef] command introduced in version 8.2a1d1 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.
to:
This file documents the new [menuRef] command in version 8.2a1d3 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.
Changed lines 6-16 from:
to:
Changed lines 32-33 from:

The [count] subcommand

This subcommand returns the number of menu items in a menu. The syntax is:

to:

The [clear] subcommand

This subcommand removes all the items from a menu. The syntax is:

Changed line 35 from:
 	menuItem count token
to:
 	menuItem clear token
Changed lines 37-39 from:

The [create] subcommand

This subcommand creates a new menu. It accepts a few options. The complete syntax is:

to:

To remove only one item from a menu list, use the [menuRef delete] command.

The [count] subcommand

This subcommand returns the number of menu items in a menu. The syntax is:

Changed line 41 from:
     menuRef create ?-attributes val? ?(-icon code|-title name)? ?-command name?
to:
 	menuItem count token
Added lines 43-48:

The [create] subcommand

This subcommand creates a new menu. It accepts a few options. The complete syntax is:

 
     menuRef create ?-attributes val? ?(-icon code|-title name)? ?-command name?

Changed line 65 from:

The [delete] subcommand

to:

The [delete] subcommand

Changed line 72 from:

The [hilite] subcommand

to:

The [hilite] subcommand

Changed line 77 from:

The [insert] subcommand

to:

The [insert] subcommand

Changed line 85 from:

The [items] subcommand

to:

The [items] subcommand

Changed line 89 from:
 	menuRef items token
to:
 	menuItem items token
Changed line 93 from:

The [list] subcommand

to:

The [list] subcommand

Changed line 101 from:

The [remove] subcommand

to:

The [remove] subcommand

Changed line 107 from:

The [set] subcommand

to:

The [set] subcommand

Changed lines 120-121 from:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus representing a fileset).
  • the -name option lets you change the name of the menu. This option is provided only for compatibility reasons: the previous menu syntax identified menus by name. By default, the name field of a menu created with the new syntax contains the menu token. Under some circumstances, one might want to modify the name of the menu to ensure that a menu created with the new syntax can be found by procs using the old syntax.
to:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus

representing a fileset).

  • the -name option lets you change the name of the menu. This option is provided only for compatibility reasons: the previous menu syntax identified menus by name. By default, the name field of a menu created with the new syntax contains the menu token. Under some circumstances, one might want to modify the name of the menu to ensure that a menu created with the new syntax can be found by procs using the old syntax.
Changed line 124 from:

Application menus

to:

Application menus

Changed line 135 from:

Examples

to:

Examples

Changed line 140 from:

(add your comments here...)

to:

(add your comments here...)

February 26, 2007, at 10:26 AM by bd - New -name option for backward compatibility
Changed line 114 from:
  • the -name option lets you change the name of the menu. This option is provided only for compatibility reasons: the previous menu syntax identified menus by name. In some circumstances one might want to set the name of the menu to ensure that a menu created with the new syntax can be found by procs using the old syntax.
to:
  • the -name option lets you change the name of the menu. This option is provided only for compatibility reasons: the previous menu syntax identified menus by name. By default, the name field of a menu created with the new syntax contains the menu token. Under some circumstances, one might want to modify the name of the menu to ensure that a menu created with the new syntax can be found by procs using the old syntax.
February 26, 2007, at 10:21 AM by bd - New -name option for backward compatibility
Changed lines 113-114 from:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus

representing a fileset).

to:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus representing a fileset).
February 26, 2007, at 10:21 AM by bd - New -name option for backward compatibility
Added line 115:
  • the -name option lets you change the name of the menu. This option is provided only for compatibility reasons: the previous menu syntax identified menus by name. In some circumstances one might want to set the name of the menu to ensure that a menu created with the new syntax can be found by procs using the old syntax.
February 19, 2007, at 05:11 AM by bd - Fixed typo in [items] syntax
Changed line 82 from:
 	menuItem items token
to:
 	menuRef items token
February 16, 2007, at 01:31 PM by bd - Modified syntax after removal of [action] command
Changed lines 3-6 from:

This file documents the new [menuRef] command introduced in version 8.1 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.

to:
This file documents the new [menuRef] command introduced in version 8.2a1d1 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.
Changed lines 113-114 from:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus representing a fileset).
to:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus

representing a fileset).

Changed lines 128-129 from:

See a series of sample instructions on the MenuItemCommand

to:

See a series of sample instructions on the MenuItem Command

Changed line 132 from:

(add your comments here...)

to:

(add your comments here...)

February 08, 2007, at 08:36 AM by bd - Table border
Changed line 51 from:
to:
February 06, 2007, at 11:25 AM by bd - Updated for 8.1a5d4
Changed lines 116-117 from:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus

representing a fileset).

to:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus representing a fileset).
February 06, 2007, at 11:24 AM by bd - Updated for 8.1a5d4
Added line 6:

February 06, 2007, at 11:24 AM by bd - Updated for 8.1a5d4
Added line 4:
Deleted line 5:

Changed line 45 from:

subcommands as well as with the [menuItemto] command uniquely

to:

subcommands (as well as with the [menuItem] command) to uniquely

Changed lines 51-54 from:
1ExcludesMarkColumnNo column space is allocated for the mark character when this menu is drawn.
4AutoDisableThe menu title is automatically disabled when all items are disabled.
16HiddenThe menu title is not drawn in the menubar, even when the menu is inserted in the menubar. Useful for adding command keys that don't correspond to a visible menu item; menu items with the desired command keys can be added to the menu and inserted in the menubar without making the menu visible.
32CondenseSeparatorsIf menu item separators are present at the beginning or end of the menu, or if multiple contiguous separators are present, the extra separator items are marked as hidden to avoid extra blank space in the menu. The menu is examined for extra separators whenever the menu size is recalculated.
to:
ValueNameDescription
1ExcludesMarkColumnNo column space is allocated for the mark character when this menu is drawn.
4AutoDisableThe menu title is automatically disabled when all items are disabled.
16HiddenThe menu title is not drawn in the menubar, even when the menu is inserted in the menubar. Useful for adding command keys that don't correspond to a visible menu item; menu items with the desired command keys can be added to the menu and inserted in the menubar without making the menu visible.
32CondenseSeparatorsIf menu item separators are present at the beginning or end of the menu, or if multiple contiguous separators are present, the extra separator items are marked as hidden to avoid extra blank space in the menu. The menu is examined for extra separators whenever the menu size is recalculated.
Changed line 57 from:
  • the -command option lets you specify the name of the Tcl proc to execute when an item is selected in this menu. Alpha will invoke this command with two additional arguments: the token of the menu and the index of the selected item (to get the text of the item use the [menuItem set -text] command).
to:
  • the -command option lets you specify the name of the Tcl proc to execute when an item is selected in this menu. Alpha will invoke this command with two arguments: the token of the menu and the index of the selected item (to get the text of the item use the [menuItem set -text] command).
Added lines 115-116:
  • the -keyMatching option lets you enable or disable key matching for the entire menu. By default, this option is set to 1 and key matching is performed when the menu is opened: this means that, for each menu item, Alpha will check if there is a binding associated with the action attached to the menu item. To speed things up, you can disable key matching in menus where you do not want items to have a keyboard shortcut, or if you know that no items have a shortcut (for instance, in the menus

representing a fileset).

January 12, 2007, at 07:51 AM by bd - Application menus section
Changed lines 17-18 from:
to:
Changed lines 115-126 from:

Examples

to:

Application menus

There are two special menus provided by the system: the application menu (which starts with the About Alpha item) and the help menu. Both menus can be targetted by the [menuRef] and [menuItem] commands using the "application" and "help" symbolic names in place of the token. For instance:

 
     menuRef count help

These menus cannot be deleted or removed using the [menuRef delete] and [menuRef remove] commands.

Examples

January 12, 2007, at 07:37 AM by bd - Transfered the [count] and [items] subcommands
Changed lines 48-54 from:
  • the -attributes option lets you specify some attributes for the menu. The default value is 0.
to:
  • the -attributes option lets you specify some attributes for the menu. The default value is 0. The value passed in the -attributes option is additive. It is the sum of base-2 constants. The only values of interest could be:
1ExcludesMarkColumnNo column space is allocated for the mark character when this menu is drawn.
4AutoDisableThe menu title is automatically disabled when all items are disabled.
16HiddenThe menu title is not drawn in the menubar, even when the menu is inserted in the menubar. Useful for adding command keys that don't correspond to a visible menu item; menu items with the desired command keys can be added to the menu and inserted in the menubar without making the menu visible.
32CondenseSeparatorsIf menu item separators are present at the beginning or end of the menu, or if multiple contiguous separators are present, the extra separator items are marked as hidden to avoid extra blank space in the menu. The menu is examined for extra separators whenever the menu size is recalculated.
Deleted lines 57-72:

The value passed in the -attributes option is additive. It is the sum of base-2 constants. The only values of interest could be:

1 (ExcludesMarkColumn)
No column space is allocated for the mark character when this menu

is drawn.

4 (AutoDisable)
The menu title is automatically disabled when all items are

disabled.

16 (Hidden)
The menu title is not drawn in the menubar, even when the menu is

inserted in the menubar. Useful for adding command keys that don't correspond to a visible menu item; menu items with the desired command keys can be added to the menu and inserted in the menubar without making the menu visible.

32 (CondenseSeparators)
If menu item separators are present at the beginning or end of the

menu, or if multiple contiguous separators are present, the extra separator items are marked as hidden to avoid extra blank space in the menu. The menu is examined for extra separators whenever the menu size is recalculated.

January 12, 2007, at 07:32 AM by bd - Transfered the [count] and [items] subcommands
Changed lines 8-15 from:
to:
Changed lines 32-34 from:

The [create] subcommand

This subcommand creates a new menu. It accepts a few options. The complete syntax is:

to:

The [count] subcommand

This subcommand returns the number of menu items in a menu. The syntax is:

Changed line 35 from:
     menuRef create ?-attributes val? ?(-icon code|-title name)? ?-command name?
to:
 	menuItem count token
Added lines 37-42:

The [create] subcommand

This subcommand creates a new menu. It accepts a few options. The complete syntax is:

 
     menuRef create ?-attributes val? ?(-icon code|-title name)? ?-command name?

Added line 46:
Changed lines 54-58 from:
1 (ExcludesMarkColumn)
No column space is allocated for the mark character when this menu is drawn.
4 (AutoDisable)
The menu title is automatically disabled when all items are disabled.
16 (Hidden)
The menu title is not drawn in the menubar, even when the menu is inserted in the menubar. Useful for adding command keys that don't correspond to a visible menu item; menu items with the desired command keys can be added to the menu and inserted in the menubar without making the menu visible.
32 (CondenseSeparators)
If menu item separators are present at the beginning or end of the menu, or if multiple contiguous separators are present, the extra separator items are marked as hidden to avoid extra blank space in the menu. The menu is examined for extra separators whenever the menu size is recalculated.

The [delete] subcommand

to:
1 (ExcludesMarkColumn)
No column space is allocated for the mark character when this menu

is drawn.

4 (AutoDisable)
The menu title is automatically disabled when all items are

disabled.

16 (Hidden)
The menu title is not drawn in the menubar, even when the menu is

inserted in the menubar. Useful for adding command keys that don't correspond to a visible menu item; menu items with the desired command keys can be added to the menu and inserted in the menubar without making the menu visible.

32 (CondenseSeparators)
If menu item separators are present at the beginning or end of the

menu, or if multiple contiguous separators are present, the extra separator items are marked as hidden to avoid extra blank space in the menu. The menu is examined for extra separators whenever the menu size is recalculated.

The [delete] subcommand

Changed line 75 from:

The [hilite] subcommand

to:

The [hilite] subcommand

Changed line 80 from:

The [insert] subcommand

to:

The [insert] subcommand

Changed lines 88-92 from:

The [list] subcommand

This subcommand returns a list of the tokens corresponding to the currently existing menus. Each time a new menu is created, its token is appended at the end of the list, so this list is ordered from the oldest to the newest menu. The syntax is:

to:

The [items] subcommand

This subcommand returns a list of all the items currently present in the menu, in the index order. The syntax is:

Changed line 92 from:
 	menuRef list
to:
 	menuItem items token
Changed lines 94-95 from:

The [remove] subcommand

This subcommand lets you remove a menu from the menu bar. The syntax is:

to:

This command should not be confused with the [menuRef list] command which returns the current list of menus.

The [list] subcommand

This subcommand returns a list of the tokens corresponding to the currently existing menus. Each time a new menu is created, its token is appended at the end of the list, so this list is ordered from the oldest to the newest menu. The syntax is:

Changed line 102 from:
     menuRef remove token
to:
 	menuRef list
Added lines 104-108:

The [remove] subcommand

This subcommand lets you remove a menu from the menu bar. The syntax is:

 
     menuRef remove token

Changed line 110 from:

The [set] subcommand

to:

The [set] subcommand

Changed line 124 from:

Examples

to:

Examples

January 11, 2007, at 08:13 PM by bd - Experimental menuRef command
Deleted line 38:
Changed lines 40-44 from:
  • the -attributes option lets you specify some attributes for the menu. The default value is 0. The value passed in the -attributes option is additive. It is the sum of base-2 constants. The only values of interest could be: ((ld ((lt 1 (ExcludesMarkColumn) No column space is allocated for the mark character when this menu is drawn. l

t))

4 (AutoDisable) The menu title is automatically disabled when all items are disabled. l
t))
16 (Hidden) The menu title is not drawn in the menubar, even when the menu is inserted in the menubar. Useful for adding command keys that don't correspond to a visible menu item; menu items with the desired command keys can be added to the menu and inserted in the menubar without making the menu visible. l
t))
32 (CondenseSeparators) If menu item separators are present at the beginning or end of the menu, or if multiple contiguous separators are present, the extra separator items are marked as hidden to avoid extra blank space in the menu. The menu is examined for extra separators whenever the menu size is recalculated. l
t)) ld))
to:
  • the -attributes option lets you specify some attributes for the menu. The default value is 0.
Added lines 44-49:

The value passed in the -attributes option is additive. It is the sum of base-2 constants. The only values of interest could be:

1 (ExcludesMarkColumn)
No column space is allocated for the mark character when this menu is drawn.
4 (AutoDisable)
The menu title is automatically disabled when all items are disabled.
16 (Hidden)
The menu title is not drawn in the menubar, even when the menu is inserted in the menubar. Useful for adding command keys that don't correspond to a visible menu item; menu items with the desired command keys can be added to the menu and inserted in the menubar without making the menu visible.
32 (CondenseSeparators)
If menu item separators are present at the beginning or end of the menu, or if multiple contiguous separators are present, the extra separator items are marked as hidden to avoid extra blank space in the menu. The menu is examined for extra separators whenever the menu size is recalculated.
January 11, 2007, at 08:00 PM by bd - Experimental menuRef command
Changed lines 1-3 from:
to:

(:title The [menuRef] command:)

January 11, 2007, at 07:57 PM by bd - Experimental menuRef command
Added lines 1-99:
This file documents the new [menuRef] command introduced in version 8.1 of AlphaX. This is an experimental command proposed as a part of the bindings reform. It is open to discussion.


Introduction

The [menuRef] command lets you create and manipulate menus in Alpha. Menu items can be manipulated using the new [menuItem] command (see the MenuItemCommand page on this wiki). Both commands could constitute a replacement for the old [Menu] command.

Synopsis

The formal syntax of the [menuRef] command is:

menuRef subcommand ?options?

The possible subcommands are described below. Depending on the subcommand, various options can be additionnally specified.

The [create] subcommand

This subcommand creates a new menu. It accepts a few options. The complete syntax is:

 
     menuRef create ?-attributes val? ?(-icon code|-title name)? ?-command name?

The [menuRef create] command returns a token used in the other subcommands as well as with the [menuItemto] command uniquely identify the menu.

Here is the description of the various options:

  • the -attributes option lets you specify some attributes for the menu. The default value is 0. The value passed in the -attributes option is additive. It is the sum of base-2 constants. The only values of interest could be: ((ld ((lt 1 (ExcludesMarkColumn) No column space is allocated for the mark character when this menu is drawn. l

t))

4 (AutoDisable) The menu title is automatically disabled when all items are disabled. l
t))
16 (Hidden) The menu title is not drawn in the menubar, even when the menu is inserted in the menubar. Useful for adding command keys that don't correspond to a visible menu item; menu items with the desired command keys can be added to the menu and inserted in the menubar without making the menu visible. l
t))
32 (CondenseSeparators) If menu item separators are present at the beginning or end of the menu, or if multiple contiguous separators are present, the extra separator items are marked as hidden to avoid extra blank space in the menu. The menu is examined for extra separators whenever the menu size is recalculated. l
t)) ld))
  • the -command option lets you specify the name of the Tcl proc to execute when an item is selected in this menu. Alpha will invoke this command with two additional arguments: the token of the menu and the index of the selected item (to get the text of the item use the [menuItem set -text] command).
  • the -icon option lets you specify a four character code corresponding to a registered icon reference in order to set the title of the menu to be an icon: see the IconrefCommand documentation on this wiki. The -icon and the -title options are mutually exclusive.
  • the -title option lets you specify the title of the menu. The -icon and the -title options are mutually exclusive.

The [delete] subcommand

This subcommand lets you delete a menu. The syntax is:

 
 	menuRef delete token

The token associated with this menu is not valid anymore and is removed from the list returned by the [menuRef list] command.

The [hilite] subcommand

This subcommand lets you hilite/unhilite a menu. The syntax is:

 
 	menuRef hilite token (0|1)

The [insert] subcommand

This subcommand lets you insert a menu in the menu bar. The syntax is:

 
 	menuRef insert token ?-before token?

The -before option lets you specify the token of another menu before which the menu must be inserted in the menu bar. If unspecified, the menu is appended at the right of the menu bar (yet before the Help menu).

The [list] subcommand

This subcommand returns a list of the tokens corresponding to the currently existing menus. Each time a new menu is created, its token is appended at the end of the list, so this list is ordered from the oldest to the newest menu. The syntax is:

 
 	menuRef list

The [remove] subcommand

This subcommand lets you remove a menu from the menu bar. The syntax is:

 
     menuRef remove token

The menu is removed but not deleted: its token remains valid.

The [set] subcommand

This subcommand lets you get or set some properties of a menu. The syntax can take two forms:

 
     menuRef set token option
     menuRef set token option value ?option value...?

In the first form the command returns the current value of the specified option. In the second form, it lets you set the value of one or several options. Here is the list of the available options:

  • the -attributes option lets you modify the attributes of the menu
  • the -command option lets you change the Tcl proc attached to the menu
  • the -icon option lets you modify the icon associated with a menu. Use an empty string to remove an icon.
  • the -title option lets you change the title of the menu.

Examples

See a series of sample instructions on the MenuItemCommand page on this wiki.


(add your comments here...)

Page last modified on September 30, 2009, at 09:03 AM
Hosted on SourceForge.net Logo