Using Menus in a FireMonkey Application

From RAD Studio
Jump to: navigation, search

Go Up to FireMonkey Application Design


FireMonkey supports both lightweight styled menus displayed on the form, and native menus.

Drop-Down Menus

Traditional desktop-OS drop-down menus are hosted in a TMenuBar, a fully styled control. It acts as the root of a tree of TMenuItem objects. The first generation of children are visible in the menu bar. Second generation items are displayed under their parent when the parent item is clicked. Later generations are displayed as sub-menus to the right.

Menu items have label Text and an optional Bitmap image. Items can be checked through the IsChecked trigger property. Setting AutoCheck to True will automatically toggle IsChecked every time the item is clicked. A group of menu items can be designated so that only one item at most is checked, by setting RadioItem to True on each item, and GroupIndex to the same arbitrary value.

Implement menu actions in the OnClick event handler. Assign the code representation of a shortcut to the ShortCut property for shortcut keys.

To create a menu separator item, set the Text to a single hyphen-minus character (Unicode code point U+002D, ASCII 45).

Creating Menus for OS X and Windows

Use the correct control for your target system (OS X vs. Windows).

  • For Windows applications, use the TMenuBar control:
    • The main menu is placed in the client area of the form (standard for Windows).
    • The menu items are not on the OS X menu bar (nonstandard for OS X).
  • For OS X applications, use the TMainMenu component:
    • The main menu is placed in the non-client area of the Windows form (nonstandard for Windows).
    • Menu items are placed on the OS X menu bar (standard for OS X).

Using Keyboard Shortcuts

To activate menu commands you can assign keyboard shortcuts in the ShortCut property of the menu item of a TMainMenu.

Topics

See Also