1=head1 NAME
2
3Prima::Menu - pull-down and pop-up menu objects
4
5=head1 SYNOPSIS
6
7   use Prima;
8   use Prima::Application;
9
10   my $window = Prima::Window-> new(
11        menuItems => [
12           [ '~File' => [
13              [ '~Open', 'Ctrl+O', '^O', \&open_file ],
14              [ '-save_file', '~Save', km::Ctrl | ord('s'), sub { save_file() } ],
15              [],
16              [ '~Exit', 'Alt+X', '@X', sub { exit } ],
17           ]],
18           [ '~Options' => [
19              [ '*option1'  => 'Checkable option' => sub { $_[0]-> menu-> toggle( $_[1]) }],
20              [ '*@option2' => 'Checkable option' => sub {}], # same
21           ]],
22           [],
23           [ '~Help' => [
24              [ 'Show help' => sub { $::application-> open_help("file://$0"); }],
25           ]],
26        ],
27    );
28
29    sub open_file
30    {
31        # enable 'save' menu item
32        $window-> menu-> save_file-> enable;
33    }
34
35    $window-> popupItems( $window-> menuItems);
36
37=head1 DESCRIPTION
38
39The document describes interfaces of Prima::AbstractMenu
40class, and its three descendants - Prima::Menu, Prima::Popup,
41and Prima::AccelTable, all aimed at different targets.
42Prima::AbstractMenu is a descendant of Prima::Component class,
43and its specialization is handling of menu items, held in
44a tree-like structure. Descendants of Prima::AbstractMenu
45are designed to be attached to widgets and windows, to serve
46as hints for the system-dependent pop-up and pull-down menus.
47
48=head1 USAGE
49
50=head2 Menu items
51
52The central point of functionality in Prima::AbstractMenu-derived classes
53and their object instances ( further referred as 'menu classes'
54and 'menu objects'), is handling of a complex structure, contained in
55C<::items> property. This property is special in that its structure
56is a tree-like array of scalars, each of whose is either a description of
57a menu item or a reference to an array.
58
59Parameters of an array must follow a special syntax, so the property
60input can be parsed and assigned correctly. In general, the syntax is
61
62   $menu-> items( [
63      [ menu item description ],
64      [ menu item description ],
65      ...
66   ]);
67
68where 'menu item description' is an array of scalars,
69that can hold from 0 up to 6 elements. Each menu item has six fields,
70that qualify a full description of a menu item;
71the shorter arrays are shortcuts,
72that imply default or special cases. These base six fields are:
73
74=over
75
76=item Menu item name
77
78A string identifier.  Menu items can be accessed individually by their names,
79and the following fields can be managed by calling elemental properties, that
80require an item name. If not given, or empty, item name is assigned a string in
81a form '#ID' where ID is the unique integer value within the menu object.
82
83IDs are set for each menu item, disregarding whether they have names or not.
84Any menu item can be uniquely identifed by its ID value, by supplying the '#ID'
85string, in the same fashion as named menu items.  When creating or copying menu
86items, names in format '#ID' are not accepted, and treated as if an empty
87string is passed. When copying menu items to another menu object, all menu
88items to be copied change their IDs, but explicitly set names are preserved.
89Since the anonymous menu items do not have name, their auto-generated names
90change also.
91
92If the name is prepended by special characters ( see below ), these characters
93are not treated as part of the name but as an item modifier.  This syntax is
94valid only for C<::items> and C<insert()> functions, not for C<set_variable()>
95method.
96
97=over
98
99=item C<-> - item is disabled
100
101=item C<*> - item is checked
102
103=item C<@> - item is using auto-toggling
104
105=item C<?> - item is customly drawn
106
107Expects C<onMeasure> and C<onPaint> callbacks in C<options>
108
109=item C<(> and C<)> - radio group
110
111Items marked with parentheses are treated as a part of a group, where only a
112single item can be checked. Checking and unchecking happens automatically.
113
114A group is only valid for the same level where it was opened on (i.e. submenus
115don't inherit it).  A group is automatically terminated on a separator item. If
116that is not desired, mark it as C<(> too (consequent C<(> are allowed):
117
118    [ '(one' ... ]
119    [ 'two' ... ]
120    [ '(' ],
121    [ ')last' ... ]
122
123When user hits an already checked item, nothing happens. However, when combined with
124auto-toggling (i.e. marked with C<(@>), a checked item becomes unchecked, thus the
125group can present a state where no items are checked, too.
126
127See also: C<group>
128
129=back
130
131=item Menu text / menu image
132
133A non-separator menu item can be visualized either as a
134text string or an image. These options are exclusive to each other,
135and therefore occupy same field. Menu text is an arbitrary string,
136with with ~ ( tilde ) quoting for a shortcut character, that the
137system uses as a hot key during menu navigation.
138Menu image is a L<Prima::Image> object of no particular color
139space and dimensions.
140
141Note: tilde-marked character is also used in navigation for custom drawn menu
142items, even though they not necessarily draw the text itself.
143
144Menu text in menu item is accessible via the C<::text> property,
145and menu image via the C<::image> property. These can not accept
146or return sensible arguments simultaneously.
147
148=item Accelerator text
149
150An alternate text string, appearing together with a menu item
151or a menu image, usually serving as a description to the hot key,
152associated with a menu item. For example, if a hot key to
153a menu item is combination of 'enter' and 'control' keys, then
154usually accelerator text is 'Ctrl+Enter' string.
155
156Accelerator text in menu item is accessible via C<::accel>
157property.
158
159NB: There is C<Prima::KeySelector::describe> function, that converts
160a key value to a string in human-readable format.
161
162=item Hot key
163
164An integer value, combined from either C<kb::XXX> constant or
165a character index with modificator key values ( C<km::XXX> constant ).
166This representation format is not that informative as three-integer
167key event format (CODE,KEY,MOD), described in L<Prima::Widget>.
168However, these formats are easily converted to each other:
169CODE,KEY,MOD is translated to INTEGER format by C<translate_key()>
170method. The reverse operation is not needed for C<Prima::AbstractMenu>
171functionality and is performed by C<Prima::KeySelector::translate_codes>
172method.
173
174The integer value can be given in a some more readable format
175when submitting to C<::items>. Character and F-keys (from F1 to F16)
176can be used literally, without C<kb::> prepending, and the modificator
177keys can be hinted as prefix characters: km::Shift as '#',
178km::Ctrl as '^' and km::Alt as '@'. This way, combination of
179'control' and 'G' keys can be expressed as C<'^G'> literal,
180and 'control'+'shift'+'F10' - as C<'^#F10'>.
181
182Hot key in menu item is accessible via C<::key>
183property. The property does accept literal key format,
184described above.
185
186A literal key string can be converted to
187an integer value by C<translate_shortcut> method.
188
189When the user presses the key combination, that matches to hot key
190entry in a menu item, its action is triggered.
191
192=item Action
193
194Every non-separator and non-submenu item is destined to perform an action. The
195action can be set either as an anonymous sub, or as string with name of a
196method on the owner of a menu object. Both have their niche of usage, and both
197are supplied with three parameters, when called - the owner of a menu object,
198the name of a menu item, that triggered the action, and the menu checked status:
199
200   Prima::MainWindow-> new(
201   	menuItems => [
202   		['@item', 'Test',
203                sub {
204                    my (
205                       $window,  # MainWindow
206                       $item,    # 'item'
207                       $checked  # MainWindow->men('item')->checked
208                    ) = @_;
209                }],
210   	]
211   );
212
213Action scalar in menu item is accessible via C<::action>
214property.
215
216A special built-in action can automatically toggle a menu item, instead of
217an explicit call
218
219   $window->menu->toggle($item)
220
221To achieve this, add '@' character to the menu item name (see L<"Menu item name">).
222
223=item Options
224
225At last, non-separator menu items can hold an extra hash in C<options> property.
226The toolkit reserves the following keys for internal use:
227
228=over
229
230=item group INTEGER
231
232Same as C<group> property.
233
234=item icon HANDLE
235
236Uses to replace default check mark bitmap on a menu item
237
238=item onMeasure MENUITEM, REF
239
240Required when custom painting is set. It is called when system needs to query
241menu item dimensions. C<REF> is a 2-item arrayref that needs to be set with
242pixel dimension.
243
244=item onPaint MENUITEM, CANVAS, SELECTED, X1, Y1, X2, Y2
245
246Required when custom painting is set. It is called whenever system needs to
247draw a menu item. X1 - Y2 are coordinates of the rectangle where the drawing is
248allowed.
249
250=back
251
252=back
253
254Syntax of C<::items> does not provide 'disabled' and 'checked'
255states for a menu item as separate fields. These states
256can be set by using '-' and '*' prefix characters, as described above,
257in L<Menu item name>. They also can be assigned on per-item
258basis via C<::enabled> and C<::checked> properties.
259
260All these fields qualify a most common menu item,
261that has text, shortcut key and an action - a 'text item'.
262However, there are also two other types of menu items -
263a sub-menu and separator. The type of a menu items
264can not be changed except by full menu item tree change
265functions ( C<::items>, C<remove()>, C<insert()>.
266
267Sub-menu item can hold same references as text menu item does,
268except the action field. Instead, the action field is used for
269a sub-menu reference scalar, pointing to another set of
270menu item description arrays. From that point of view, syntax of C<::items>
271can be more elaborated and shown as
272
273   $menu-> items( [
274      [ text menu item description ],
275      [ sub-menu item description [
276
277         [ text menu item description ],
278         [ sub-menu item description [
279             [ text menu item description ],
280             ...
281         ]
282         [ text menu item description ],
283         ...
284      ] ],
285      ...
286   ]);
287
288Separator items do not hold any fields, except name.
289Their purpose is to hint a logical division of menu items
290by the system, which visualizes them usually as non-selectable
291horizontal lines.
292
293In menu bars, the first separator item met by parser is
294treated differently. It serves as a hint, that the following
295items must be shown in the right corner of a menu bar, contrary
296to the left-adjacent default layout. Subsequent separator items
297in a menu bar declaration can be either shown as a vertical
298division bars, or ignored.
299
300With these menu items types and fields, it is possible
301to construct the described above menu description arrays.
302An item description array can hold from 0 to 6 scalars,
303and each combination is treated differently.
304
305=over
306
307=item six - [ NAME, TEXT/IMAGE, ACCEL, KEY, ACTION/SUBMENU, DATA ]
308
309Six-scalar array is a fully qualified text-item description.
310All fields correspond to the described above scalars.
311
312=item five [ NAME, TEXT/IMAGE, ACCEL, KEY, ACTION/SUBMENU ]
313
314Same as six-scalar syntax, but without DATA field.
315If DATA is skipped it is C<undef> by default.
316
317=item four [ TEXT/IMAGE, ACCEL, KEY, ACTION/SUBMENU ] or [ NAME, TEXT/IMAGE, ACTION/SUBMENU, DATA ]
318
319One of two, depending whether last item is a hashref or not.
320
321If not, same as five-scalar syntax, but without NAME field.
322When NAME is skipped it is assigned to an unique string
323within menu object.
324
325Otherwise same as three-scalar plus DATA hashref.
326
327=item three [ NAME, TEXT/IMAGE, ACTION/SUBMENU ] or [ TEXT/IMAGE, ACTION/SUBMENU, DATA ]
328
329One of two, depending whether last item is a hashref or not.
330
331In not, same as five-scalar syntax, but without ACCEL and KEY fields.
332KEY is C<kb::NoKey> by default, so no keyboard combination
333is bound to the item. Default ACCEL value is an empty string.
334
335Otherwise same as two-scalar plus DATA hashref.
336
337=item two [ TEXT/IMAGE, ACTION/SUBMENU ] or [ NAME, DATA ]
338
339One of two, depending whether last item is a hashref or not.
340
341If not, same as three-scalar syntax, but without NAME field.
342
343Otherwise name with data reference. Useful for custom menu items that need at
344least the C<'?'> flag in the NAME.
345
346=item one and zero [ ]
347
348Both empty and 1-scalar arrays indicate a separator
349menu item. In case of 1-scalar syntax, the scalar value
350is ignored.
351
352=back
353
354As an example of all above said, a real-life piece of code
355is exemplified:
356
357   $img = Prima::Image-> create( ... );
358   ...
359   $menu-> items( [
360      [ "~File" => [
361          [ "Anonymous" => "Ctrl+D" => '^d' => sub { print "sub\n";}],   # anonymous sub
362          [ $img => sub {
363             my $img = $_[0]-> menu-> image( $_[1]);
364             my @r = @{$img-> palette};
365             $img-> palette( [reverse @r]);
366             $_[0]->menu->image( $_[1], $img);
367          }],                         # image
368          [],                         # division line
369          [ "E~xit" => "Exit"    ]    # calling named function of menu owner
370      ]],
371      [ ef => "~Edit" => [                  # example of system commands usage
372         ...
373         [ "Pa~ste" => sub { $_[0]->foc_action('paste')} ],
374         ...
375         ["~Duplicate menu"=>sub{ TestWindow->create( menu=>$_[0]->menu)}],
376      ]],
377      ...
378      [],                             # divisor in main menu opens
379      [ "~Clusters" => [              # right-adjacent part
380        [ "*".checker =>  "Checking Item"   => "Check"     ],
381        [],
382        [ "-".slave   =>  "Disabled state"   => "PrintText"],
383        ...
384      ]]
385   ] );
386
387The code is stripped from 'menu.pl' from 'examples' directory
388in the toolkit installation. The reader is advised to
389run the example and learn the menu mechanics.
390
391=head2 Prima::MenuItem
392
393As described above, text and sub-menu items can be managed
394by elemental properties - C<::accel>, C<::text>, C<::image>,
395C<::checked>, C<::enabled>, C<::action>, C<::data>.
396All these, plus some other methods can be called in an
397alternative way, resembling name-based component calls
398of L<Prima::Object>. A code
399
400  $menu-> checked('CheckerMenuItem', 1);
401
402can be re-written as
403
404  $menu-> CheckerMenuItem-> checked(1);
405
406Name-based call substitutes Prima::MenuItem object,
407created on the fly. Prima::MenuItem class shares
408same functions of Prima::AbstractMenu, that handle
409individual menu items.
410
411=head2 Prima::Menu
412
413Objects, derived from Prima::Menu class are
414used to tandem Prima::Window objects, and their
415items to be shown as menu bar on top of the window.
416
417Prima::Menu is special in that its top-level items
418visualized horizontally, and in behavior of the top-level
419separator items ( see above, L<Menu items> ).
420
421If C<::selected> is set to 1, then a menu object
422is visualized in a window, otherwise it is not.
423This behavior allows window to host multiple
424menu objects without clashing.
425When a Prima::Menu object gets 'selected', it displaces
426the previous 'selected' menu Prima::Menu object, and its items
427are installed into the visible menu bar. Prima::Window
428property C<::menu> then points to the menu object, and
429C<::menuItems> is an alias for C<::items> menu class property.
430Prima::Window's properties C<::menuFont> and C<::menuColorIndex>
431are used as visualization hints.
432
433Prima::Menu provides no new methods or properties.
434
435=head2 Prima::Popup
436
437Objects, derived from Prima::Popup class are
438used together with Prima::Widget objects.
439Menu items are visualized when the user pressed
440the pop-up key or mouse buttons combination,
441in response to Prima::Widget's C<Popup> notification.
442
443If C<::selected> is set to 1, then a menu object
444is visualized in the system pop-up menu, otherwise it is not.
445This behavior allows widget to host multiple
446menu objects without clashing.
447When a Prima::Popup object gets 'selected', it displaces
448the previous 'selected' menu Prima::Popup object.
449Prima::Widget
450property C<::popup> then points to the menu object, and
451C<::popupItems> is an alias for C<::items> menu class property.
452Prima::Widget's properties C<::popupFont> and C<::popupColorIndex>
453are used as visualization hints.
454
455A Prima::Popup object can be visualized
456explicitly, by means of C<popup> method. The
457implicit visualization by the user is happened only
458if the C<::autoPopup> property is set to 1.
459
460Prima::Popup provides new C<popup> method
461and new C<::autoPopup> property.
462
463=head2 Prima::AccelTable
464
465This class is destined for a more limited functionality than Prima::Menu and Prima::Popup,
466primarily for mapping key strokes to predefined actions.
467Prima::AccelTable objects are never visualized, and
468consume no system resources, although full menu
469item management syntax is supported.
470
471If C<::selected> is set to 1, then it displaces
472the previous 'selected' menu Prima::AccelTable object.
473Prima::Widget property C<::accelTable> then points to
474the menu object, and C<::accelItems> is an alias for
475C<::items> menu class property.
476
477Prima::AccelTable provide no new methods or properties.
478
479=head1 API
480
481=head2 Properties
482
483=over
484
485=item accel NAME, STRING / Prima::MenuItem::accel STRING
486
487Manages accelerator text for a menu item.
488NAME is name of the menu item.
489
490=item action NAME, SCALAR / Prima::MenuItem::action SCALAR.
491
492Manages action for a menu item.
493NAME is name of the menu item.
494SCALAR can be either an anonymous sub or a method name,
495defined in the menu object owner's name space.
496Both called with three parameters -
497the owner of a menu object, the menu object itself and
498the name of the menu item.
499
500=item autoPopup BOOLEAN
501
502Only in Prima::Popup
503
504If set to 1 in selected state, calls C<popup()> action
505in response to C<Popup> notification, when the user
506presses the default key or mouse button combination.
507
508If 0, the pop-up menu can not be executed implicitly.
509
510Default value: 1
511
512=item autoToggle NAME, SCALAR / Prima::MenuItem::autoToggle SCALAR.
513
514Manages autoToggle flag for a menu item. When set, C<checked> option is flipped
515when user selects the item. Also, un the unchecked state the system displays an
516empty check box icon where normally a check icon would appear, to hint the user
517that an item is a toggle, despite being unchecked.
518
519=item checked NAME, BOOLEAN / Prima::MenuItem::checked BOOLEAN
520
521Manages 'checked' state of a menu item. If 'checked',
522a menu item visualized with a distinct check-mark near
523the menu item text or image. Its usage with sub-menu
524items is possible, although discouraged.
525
526NAME is name of the menu item.
527
528=item data NAME, SCALAR / Prima::MenuItem::data SCALAR
529
530Manages the user data scalar.
531
532NAME is name of the menu item.
533SCALAR can be any scalar value, the toolkit does
534not use this property internally.
535
536=item enabled NAME, BOOLEAN / Prima::MenuItem::enabled BOOLEAN
537
538Manages 'enabled' state of a menu item. If 'enabled' is set, a menu
539item visualized with grayed or otherwise dimmed color palette. If a sub-menu
540item is disabled, whole sub-menu is inaccessible.
541
542Default: true
543
544NAME is name of the menu item.
545
546=item group NAME, INTEGER / Prima::MenuItem::group INTEGER
547
548If not 0, treated as a member of radio group with that number when checked.
549I.e. if one of the group is checked, others are unchecked.
550
551=item image NAME, OBJECT / Prima::MenuItem::image OBJECT
552
553Manages the image, bound with a menu item. OBJECT
554is a non-null Prima::Image object reference, with
555no particular color space or dimensions ( because
556of dimensions, its usage in top-level Prima::Menu
557items is discouraged ).
558
559C<::image> and C<::text> are mutually exclusive menu
560item properties, and can not be set together, but
561a menu item can change between image and text representation
562at run time by calling these properties.
563
564NAME is name of the menu item.
565
566=item items SCALAR
567
568Manages the whole menu items tree. SCALAR is
569a multi-level anonymous array structure, with
570syntax described in L<Menu items>.
571
572C<::items> is an ultimate tool for reading
573and writing the menu items tree, but often
574it is too powerful, so there are elemental
575properties C<::accel>, C<::text>, C<::image>,
576C<::checked>, C<::enabled>, C<::action>,
577C<::data> declared, that handle menu items
578individually.
579
580=item key NAME, KEY / Prima::MenuItem::key KEY
581
582Manages the hot key combination, bound with a menu item.
583Internally KEY is kept as an integer value, and get-mode
584call returns integers only, but set-mode accepts
585the literal key format - like, '^C', 'F5' strings.
586
587NAME is name of the menu item, KEY is an integer value.
588
589=item selected BOOLEAN
590
591If set to 1, menu object is granted extra functionality
592from a window or widget owner object. Different Prima::AbstractMenu
593descendant provided with different extra functionalities.
594In I<Usage> section, see L<Prima::Menu>, L<Prima::Popup>
595and L<Prima::AccelTable>.
596
597Within each menu class, only one menu object can be selected
598for its owner.
599
600If set to 0, the only actions performed are
601implicit hot-key lookup when on C<KeyDown> event.
602
603Default value: 1
604
605=item submenu NAME, ARRAY / Prima::MenuItem::submeny ARRAY
606
607Manages submenu, if present on the item. On reading, is equivalent
608to C<get_items(NAME, 1)>. On writing, removes all items under NAME
609and inserts new ones.
610
611See also: L<is_submenu>.
612
613=item text NAME, STRING / Prima::MenuItem::text STRING
614
615Manages the text, bound with a menu item. STRING
616is an arbitrary string, with '~' ( tilde ) quotation
617of a hot key character. The hot key character is only used
618when keyboard navigation of a pop-up or a pull-down menu
619is performed; it has no influence outside menu sessions.
620
621C<::text> and C<::image> are mutually exclusive menu
622item properties, and can not be set together, but
623a menu item can change between image and text representation
624at run time by calling these properties.
625
626=back
627
628=head2 Methods
629
630=over
631
632=item check NAME / Prima::MenuItem::check
633
634Alias for C<checked(1)>.
635Sets menu item in checked state.
636
637=item disable NAME / Prima::MenuItem::disable
638
639Alias for C<enabled(0)>.
640Sets menu item in disabled state.
641
642=item enabled NAME / Prima::MenuItem::enabled
643
644Alias for C<enabled(1)>.
645Sets menu item in enabled state.
646
647=item execute NAME
648
649Calls the action associated with the menu item
650
651=item find_item_by_key KEY
652
653Finds items by the associated hot key combination
654
655=item get_handle
656
657Returns a system-dependent menu handle.
658
659NB: Prima::AccelTable use no system resources, and
660this method returns its object handle instead.
661
662=item get_children NAME
663
664Returns list of NAME's children
665
666=item get_item NAME, FULL_TREE = 0
667
668Returns items entry corresponding to NAME, with or without eventual full tree
669of children items, depending on FULL_TREE flag.
670
671=item get_item NAMES, FULL_TREE = 0
672
673Returns immediate children items entries that have NAME as a parent, with or
674without eventual full tree of children items, depending on FULL_TREE flag.
675
676=item has_item NAME
677
678Returns boolean value, whether the menu object has
679a menu item with name NAME.
680
681=item insert ITEMS, ROOT_NAME, INDEX
682
683Inserts menu item inside existing item tree.
684ITEMS has same syntax as C<::items>.
685ROOT_NAME is the name of a menu item, where the insertion
686must take place; if ROOT_NAME is an empty string, the
687insertion is performed to the top level items.
688INDEX is an offset, which the newly inserted items
689would possess after the insertion. INDEX 0 indicates
690the beginning, thus.
691
692Returns no value.
693
694=item is_separator NAME
695
696Returns true if the item is a separator, false otherwise
697
698=item is_submenu NAME
699
700Returns true if the item has submenu, false otherwise
701
702=item popup X_OFFSET, Y_OFFSET, [ LEFT = 0, BOTTOM = 0, RIGHT = 0, TOP = 0 ]
703
704Only in Prima::Popup
705
706Executes the system-driven pop-up menu, in location near
707(X_OFFSET,Y_OFFSET) pixel on the screen, with items from C<::items>
708tree. The pop-up menu is hinted to be positioned so that
709the rectangle, defined by (LEFT,BOTTOM) - (RIGHT,TOP) coordinates
710is not covered by the first-level menu. This is useful when a pop-up
711menu is triggered by a button widget, for example.
712
713If during the execution the user selects a menu item,
714then its associated action is executed ( see C<action> ).
715
716The method returns immediately and returns no value.
717
718=item remove NAME / Prima::MenuItem::remove
719
720Deletes a menu item from the items tree, and
721its sub-menus if the item is a sub-menu item.
722
723=item select
724
725Alias for C<selected(1)>.
726Sets menu object in selected state.
727
728=item set_variable NAME, NEW_NAME
729
730Changes the name of a menu item with NAME to NEW_NAME.
731NEW_NAME must not be an empty string and must not be in a
732'#integer' form.
733
734=item toggle NAME / Prima::MenuItem::toggle
735
736Toggles the checked state of a menu item
737and returns the new state.
738
739=item translate_accel TEXT
740
741Locates a '~' ( tilde ) - escaped character in a TEXT
742string and returns its index ( as ord(lc())), or 0
743if no escaped characters were found.
744
745The method can be called with no object.
746
747=item translate_key CODE, KEY, MOD
748
749Translates three-integer key representation into
750the one-integer format and returns the integer value.
751The three-integer format is used in
752C<KeyDown> and C<KeyUp> notifications for Prima::Widget.
753
754See L<Prima::Widget>
755
756The method can be called with no object.
757
758=item translate_shortcut KEY
759
760Converts literal-represented KEY string
761into the integer format and returns the integer value.
762
763The method can be called with no object.
764
765=item uncheck NAME / Prima::MenuItem::uncheck
766
767Alias for C<checked(0)>.
768Sets menu item in unchecked state.
769
770=back
771
772=head2 Events
773
774=over
775
776=item Change ACTION [, NAME [, VALUE ]]
777
778Triggered when structure of the menu tree is changed. ACTION is the method call that triggered that action, and NAME
779is the menu item namem, when applicable. If empty string, means root. VALUE is the new value, if applicable.
780
781=item ItemMeasure ITEMID, REF
782
783Called when system needs to query dimensions of a menu item that has custom
784painting bit set. C<REF> is a 2-item arrayref that needs to be set with pixel
785dimension.
786
787See also: L<Options>
788
789=item ItemPaint CANVAS, ITEMID, SELECTED, X1, Y1, X2, Y2
790
791Called whenever system needs to draw a menu item that has custom painting bit
792set. X1 - Y2 are coordinates of the rectangle where the drawing is allowed.
793
794See also: L<Options>
795
796
797=back
798
799=head1 BUGS
800
801Menu colors and fonts don't work on Windows and probably never will.
802
803=head1 AUTHOR
804
805Dmitry Karasik, E<lt>dmitry@karasik.eu.orgE<gt>.
806
807=head1 SEE ALSO
808
809L<Prima>, L<Prima::Object>, L<Prima::Widget>,
810L<Prima::Window>
811
812