Show: Delphi C++
Display Preferences

Using Menus in a FireMonkey Application

From RAD Studio XE2
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 keycodes (virtual key constants added to TShortCut constants for modifier keys) 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).

Native Menus

Setting the TMenuBar.UseOSMenu property to True causes FireMonkey to create the menu tree with OS calls, resulting in a native menu. On Windows, this menu is at the top of the parent form, and displayed using the current Appearance theme. On Mac OS X, the menu is displayed in the global menu bar on top of the main screen whenever the application has focus.

See Also

Personal tools
Previous Versions
In other languages