NAME

Tk::AppWindow::Ext::MenuBar - handling menu's and stuff.

SYNOPSIS

my $app = new Tk::AppWindow(@options,
   -extensions => ['MenuBar'],
);
$app->MainLoop;

DESCRIPTION

Adds a menu to your application.

CONFIG VARIABLES

Switch: -automenu

Default value 1.

Specifies if the menu items of all extensions should be loaded automatically.

Switch: -mainmenuitems

Default value [].

Configure your menu here. See the section CONFIGURING MENUS below.

Switch: -menucolspace

Default value 3

Space between the colums in a menu item.

Switch: -menuiconsize

Default value 16

METHODS

Same as menuCreate, but binds it unpost at <Leave> basically turning it into a context menu.

Returns a Tk::Menu object. It's items in @menulist are according to the section below CONFIGURING MENUS.

Returns a reference to a list that can be used as the -menuitems at menu creation. So:

my $menu = $w->Menu(-menuitems => $menubar->menuStack(@menulist);

Items in @menulist are according to the section below CONFIGURING MENUS.

CONFIGURING MENUS

Feeding the -menuitems switch and the MenuItems methods of extensions is done with a two dimensional list. In Perl:

my $app = new Tk::AppWindow(@options,
   -extensions => ['MenuBar'],
   -menuitems => [
      [ $type, $path,  @options ],
      [ $type2, $path2,  @options2 ],
   ],
);
$app->MainLoop;

Variables used below have the following meaning:

$path

Determines where the menu entry should be placed. Lets document by example. Suppose you have a menu structure like this:

~File -> ~Open
      -> ~Close

Where ~File is a submenu on the main menu bar and ~Open and ~close are it's entries.

$path = undef

Adds your item to the end of the main menubar.

$path = 'File'

Inserts your item in the main menubar before ~File

$path = 'File|'

Inserts your item in the main menubar after ~File

$path = 'File::'

Adds your item to the end of the ~File menu

$path = 'File::Close'

Inserts your item in the ~File menu before the ~Close entry

$path = 'File::Open|'

Inserts your item in the ~File menu after the ~Open entry

$label

The name of the menu entry. You can use the '~' to indicate a shortcut.

$cmd

The command executed or event generated on selection of the menu item. A command should be defined with cmdConfig. You can set it to undef if no command is needed.

$icon

The name of an icon available through the getArt method. You can set it to undef if you do not want an icon.

$config

For checkbutton and radiobutton entries. The config variable linked to this entry. You can set it to undef if no config variable needs to be involved.

$keyboard

The name of the keyboard shortcut to be associated with this entry. The notation is that of modern desktops. The keyboard bindings will actually be created. If you don't want this you can add a '*' in front. Examples:

CTRL+A
SHIFT+F10
*CTRL+C
$offvalue
$onvalue

For checkbutton entries. If you do not specify them they default to 0 and 1.

$value

For radiobutton entries.

$values

A reference to a list of values: ['value1', 'value2'].

The following types are available:

['menu', $path, $label, $cmd, $icon],

Creates a submenu.

['menu_normal', $path, $label, $cmd, $icon, $keyboard],

Creates a command entry.

['menu_check', $path, $label, $icon, $config, $cmd, $offvalue, $onvalue],

Creates a checkbutton entry.

['menu_radio', $path, $label, $icon, $config, $cmd, $value],

Creates a radiobutton entry.

['menu_radio_s', $path, $label, $values, $icon, $config, $cmd],

Creates a submenu with a group of radiobuttons.

['menu_separator', $path, $label],

Creates a separator. Although separators do not need a label, we prefer to still do so. They act as a path indicator for the path of other entries.

AUTHOR

Hans Jeuken (hanje at cpan dot org)

BUGS

Unknown. If you find any, please contact the author.

SEE ALSO

Tk::AppWindow
Tk::AppWindow::BaseClasses::Extension