NAME
LibUI::Menu - Application-Level Menu Bar
SYNOPSIS
use LibUI ':all';
use LibUI::Window;
use LibUI::Menu;
Init && die;
my $mnuFile = LibUI::Menu->new('File');
$mnuFile->appendItem('New')->onClicked( sub { warn 'File>New' }, undef );
$mnuFile->appendItem('Open');
$mnuFile->appendItem('Save');
$mnuFile->appendItem('Save As...');
$mnuFile->appendSeparator;
$mnuFile->appendItem(__FILE__); # reopen
my $mnuFileQuit = $mnuFile->appendQuitItem;
LibUI::onShouldQuit(
sub {
return 1;
},
undef
);
my $mnuEdit = LibUI::Menu->new('Edit');
my $mnuHelp = LibUI::Menu->new('Help');
my $window = LibUI::Window->new( 'Hi', 320, 100, 1 );
$window->onClosing(
sub {
Quit();
return 1;
},
undef
);
$window->show;
Main();
DESCRIPTION
A LibUI::Menu object represents an application level menu bar.
The various operating systems impose different requirements on the creation and placement of menu bar items, hence the abstraction of the items Quit
, Preferences
and About
.
An exemplary, cross platform menu bar:
File
New
Open
Save
Quit, use appendQuitItem()
Edit
Undo
Redo
Cut
Copy
Paste
Select All
Preferences, use appendPreferencesItem()
Help
About, use appendAboutItem()
Functions
Not a lot here but... well, it's just a menu.
new( ... )
my $mnu = LibUI::Menu->new("File");
Creates a new menu.
Typical values are File
, Edit
, Help
.
appendAboutItem( )
my $mnu_abt = $mnu->appendAboutItem();
Appends a new About
menu item.
Only one such menu item may exist per application.
appendCheckItem( ... )
my $mnu_chk = $mnu->appendCheckItem( 'Read only' );
Appends a generic menu item with a checkbox.
appendItem( ... )
my $mnu_itm = $mnu->appendItem( 'Find...' );
Appends a generic menu item.
appendPreferencesItem( )
my $mnu_pref = $mnu->appendPreferencesItem;
Appends a new Preferences
menu item.
Only one such menu item may exist per application.
appendQuitItem( )
my $mnu_quit = $mnu->appendQuitItem( );
Appends a new Quit
menu item.
Only one such menu item may exist per application.
Ranther than calling onClicked( ... )
on a Quit
item, use LibUI::onShouldQuit( ... )
instead.
appendSeparator( )
my $mnu_quit = $mnu->appendSeparator( );
Appends a new separator.
See Also
LICENSE
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Sanko Robinson <sanko@cpan.org>