.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Menu::Item 3" .TH Menu::Item 3 2023-07-25 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Tk::Menu::Item \- Base class for Menu items .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& require Tk::Menu::Item; \& \& my $but = $menu\->Button(...); \& $but\->configure(...); \& my $what = $but\->cget(); \& \& package Whatever; \& require Tk::Menu::Item; \& @ISA = qw(Tk::Menu::Item); \& \& sub PreInit \& { \& my ($class,$menu,$info) = @_; \& $info\->{\*(Aq\-xxxxx\*(Aq} = ... \& my $y = delete $info\->{\*(Aq\-yyyy\*(Aq}; \& } .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Tk::Menu::Item is the base class from which Tk::Menu::Button, Tk::Menu::Cascade, Tk::Menu::Radiobutton and Tk::Menu::Checkbutton are derived. There is also a Tk::Menu::Separator. .PP Constructors are declared so that \f(CW$menu\fR\->Button(...) etc. do what you would expect. .PP The \f(CW\*(C`\-label\*(C'\fR option is pre-processed allowing ~ to be prefixed to the character to derive a \f(CW\*(C`\-underline\*(C'\fR value. Thus .PP .Vb 1 \& $menu\->Button(\-label => \*(AqGoto ~Home\*(Aq,...) \& \& is equivalent to \& \& $menu\->Button(\-label => \*(AqGoto Home\*(Aq, \-underline => 6, ...) .Ve .PP The \f(CW\*(C`Cascade\*(C'\fR menu item creates a sub-menu and accepts these options: .IP \fB\-menuitems\fR 4 .IX Item "-menuitems" A list of items for the sub-menu. Within this list (which is also accepted by Menu and Menubutton) the first two elements of each item should be the "constructor" name and the label: .Sp .Vb 4 \& \-menuitems => [ \& [Button => \*(Aq~Quit\*(Aq, \-command => [destroy => $mw]], \& [Checkbutton => \*(Aq~Oil\*(Aq, \-variable => \e$oil], \& ] .Ve .IP \fB\-postcommand\fR 4 .IX Item "-postcommand" A callback to be invoked before posting the menu. .IP \fB\-tearoff\fR 4 .IX Item "-tearoff" Specifies whether sub-menu can be torn-off or not. .IP \fB\-menuvar\fR 4 .IX Item "-menuvar" Scalar reference that will be set to the newly-created sub-menu. .PP The returned object is currently a blessed reference to an array of two items: the containing Menu and the 'label'. Methods \f(CW\*(C`configure\*(C'\fR and \f(CW\*(C`cget\*(C'\fR are mapped onto underlying \f(CW\*(C`entryconfigure\*(C'\fR and \f(CW\*(C`entrycget\*(C'\fR. .PP The main purpose of the OO interface is to allow derived item classes to be defined which pre-set the options used to create a more basic item. .SH BUGS .IX Header "BUGS" This OO interface is very new. Using the label as the "key" is a problem for separaror items which don't have one. The alternative would be to use an index into the menu but that is a problem if items are deleted (or inserted other than at the end). .PP There should probably be a PostInit entry point too, or a more widget like defered 'configure'.