NAME
TUI::Menus::MenuView - abstract base class for menu views
HIERARCHY
TObject
TView
TMenuView
TMenuBar
TMenuBox
DESCRIPTION
TMenuView implements the shared behavior required by menu views such as TMenuBar and TMenuBox. It manages menu navigation, item selection, hotkey handling, and modal execution of menus.
This class is abstract and is not intended to be instantiated directly. Applications normally interact with derived classes rather than with TMenuView itself.
Most methods defined here are used internally by the menu system and are rarely called directly by application code.
ATTRIBUTES
The following attributes are managed internally and exposed as read-only accessors.
-
Reference to the menu data structure defining the menu items (TMenu).
- parentMenu
-
Optional reference to the parent menu view (TMenuView).
- current
-
Reference to the currently selected menu item (TMenuItem).
CONSTRUCTOR
new
my $view = TMenuView->new(
bounds => $bounds,
menu => $menu,
parentMenu => $parentMenu
);
Creates a new menu view. This constructor is intended to be called only by derived classes such as TMenuBar and TMenuBox.
- bounds
-
Bounding rectangle of the menu view (TRect).
-
Menu data structure defining the menu items (TMenu).
- parentMenu
-
Optional parent menu view (TMenuView).
new_TMenuView
my $view = new_TMenuView($bounds, | $menu, | $parentMenu);
Factory-style constructor using positional arguments.
This constructor exists primarily for internal use and for compatibility with traditional Turbo Vision construction patterns.
METHODS
current
my $item = $view->current();
$view->current($item);
Gets or sets the currently selected menu item.
execute
my $command = $view->execute();
Executes the menu view in a modal loop and returns the selected command identifier, or 0 if the menu was cancelled.
findItem
my $item = $view->findItem($ch);
Searches for a menu item matching the specified shortcut character and returns the corresponding menu item, or undef if no match is found.
getHelpCtx
my $ctx = $view->getHelpCtx();
Returns the help context associated with the currently selected menu item.
getItemRect
my $rect = $view->getItemRect($item | undef);
Returns the screen rectangle occupied by the specified menu item.
getPalette
my $palette = $view->getPalette();
Returns the color palette used to draw the menu view.
handleEvent
$view->handleEvent($event);
Processes keyboard and mouse events for menu navigation and selection.
hotKey
my $item = $view->hotKey($keyCode);
Searches for a menu item matching the specified hot key and returns it if found.
newSubView
my $subView = $view->newSubView($bounds, $menu, $parentMenu);
Creates a new submenu view associated with this menu view.
parentMenu
my $parent = $view->parentMenu();
$view->parentMenu($parent);
Gets or sets the parent menu view.
SEE ALSO
TUI::Menus::MenuBar, TUI::Menus::MenuBox, TUI::Menus::Menu, TUI::Menus::MenuItem
AUTHORS
Borland International (original Turbo Vision design)
J. Schneider <brickpool@cpan.org> (Perl implementation and maintenance)
COPYRIGHT AND LICENSE
Copyright (c) 1990-1994, 1997 by Borland International
Copyright (c) 2025-2026 the "AUTHORS" as listed above.
This software is licensed under the MIT license (see the LICENSE file, which is part of the distribution).