xtd 1.0.0
Loading...
Searching...
No Matches
Inheritance diagram for xtd::forms::menu_item:
xtd::forms::menu xtd::forms::component xtd::iequatable< menu > xtd::object xtd::interface xtd::extensions::equality_operators< menu, iequatable< menu > >

Definition

Represents an individual item that is displayed within a main_menu or context_menu.

Header
#include <xtd/forms/menu_item>
Namespace
xtd::forms
Library
xtd.forms

Protected Attributes

friend main_menu
friend context_menu
Protected Attributes inherited from xtd::forms::menu
friend menu_item

Public Events

xtd::event< menu_item, xtd::event_handlerclick
 Occurs when the menu item is clicked or selected using a shortcut key or access key defined for the menu item.

Public Constructors

 menu_item ()
 Initializes a menu_item with a blank caption.
 menu_item (const xtd::string &text)
 Initializes a new instance of the menu_item class with a specified caption for the menu item.
 menu_item (const xtd::string &text, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, const xtd::drawing::image &image)
 Initializes a new instance of the class with a specified caption, and image menu item.
 menu_item (const xtd::string &text, const xtd::drawing::image &image, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, and image menu item, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, xtd::forms::menu_item_kind kind)
 Initializes a new instance of the class with a specified caption, and kind the menu item.
 menu_item (const xtd::string &text, xtd::forms::menu_item_kind kind, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, kind the menu item, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind)
 Initializes a new instance of the class with a specified caption, image menu item, and kind the menu item.
 menu_item (const xtd::string &text, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, xtd::forms::menu_item_kind kind, bool checked)
 Initializes a new instance of the class with a specified caption, kind the menu item and checked.
 menu_item (const xtd::string &text, xtd::forms::menu_item_kind kind, bool checked, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, kind the menu item, checked, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, bool checked)
 Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, and checked.
 menu_item (const xtd::string &text, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, bool checked, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, checked, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, xtd::event_handler on_click)
 Initializes a new instance of the class with a specified caption and event handler for the Click event of the menu item.
 menu_item (const xtd::string &text, xtd::event_handler on_click, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, event handler, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, xtd::event_handler on_click, const xtd::drawing::image &image)
 Initializes a new instance of the class with a specified caption, event handler, and image menu item.
 menu_item (const xtd::string &text, xtd::event_handler on_click, const xtd::drawing::image &image, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, event handler, and image menu item, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, xtd::event_handler on_click, xtd::forms::menu_item_kind kind)
 Initializes a new instance of the class with a specified caption, event handler, and kind the menu item.
 menu_item (const xtd::string &text, xtd::event_handler on_click, xtd::forms::menu_item_kind kind, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, event handler, kind the menu item, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, xtd::event_handler on_click, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind)
 Initializes a new instance of the class with a specified caption, event handler, image menu item, and kind the menu item.
 menu_item (const xtd::string &text, xtd::event_handler on_click, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, xtd::event_handler on_click, xtd::forms::menu_item_kind kind, bool checked)
 Initializes a new instance of the class with a specified caption, event handler, kind the menu item and checked.
 menu_item (const xtd::string &text, xtd::event_handler on_click, xtd::forms::menu_item_kind kind, bool checked, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, event handler, kind the menu item, checked, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, xtd::event_handler on_click, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, bool checked)
 Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, and checked.
 menu_item (const xtd::string &text, xtd::event_handler on_click, const xtd::drawing::image &image, xtd::forms::menu_item_kind kind, bool checked, xtd::forms::shortcut shortcutshortcut)
 Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, checked, and associated shortcut key for the menu item.
 menu_item (const xtd::string &text, const std::vector< menu_item_ref > &items)
 Initializes a new instance of the class with a specified caption and an array of submenu items defined for the menu item.
 menu_item (menu_item &&)=default
 menu_item (const menu_item &)=default
menu_itemoperator= (const menu_item &)=default

Public Properties

auto menu_id () const noexcept -> xtd::intptr
 Gets a value indicating the Windows identifier for this menu item.
auto checked () const noexcept -> bool
 Gets a value indicating whether a check mark appears next to the text of the menu item.
auto checked (bool value) -> menu_item &
 Sets a value indicating whether a check mark appears next to the text of the menu item.
auto enabled () const noexcept -> bool
 Gets a value indicating whether the menu item is enabled.
auto enabled (bool value) -> menu_item &
 Gets a value indicating whether the menu item is enabled.
auto is_parent () const noexcept -> bool override
 Gets a value indicating whether this menu contains any menu items.
auto kind () const noexcept -> xtd::forms::menu_item_kind
 Gets a value that represents the kind of menu item.
auto kind (xtd::forms::menu_item_kind value) -> menu_item &
 Sets a value that represents the kind of menu item.
auto shortcut () const noexcept -> xtd::forms::shortcut
 Gets a value indicating the shortcut key associated with the menu item.
auto shortcut (xtd::forms::shortcut value) -> menu_item &
 Sets a value indicating the shortcut key associated with the menu item.
auto text () const noexcept -> const xtd::string &
 Gets a value indicating the caption of the menu item.
auto text (const xtd::string &value) -> menu_item &
 Sets a value indicating the caption of the menu item.

Public Methods

void perform_click ()
 Generates a xtd::forms::menu_item::click event for the xtd::forms::menu_item, simulating a click by a user.
auto to_string () const noexcept -> xtd::string override
 Returns a string that represents the menu control.

Protected Methods

auto create_menu_handle () -> xtd::intptr override
 Creates a new handle to the Menu.
auto destroy_menu_handle (xtd::intptr handle) -> void override
 Destroys the handle to the Menu.
virtual auto on_click (const event_args &e) -> void
 Raises the Click event.
auto on_item_added (xtd::usize pos, menu_item_ref item) -> void override
auto on_item_removed (xtd::usize pos, menu_item_ref item) -> void override

Additional Inherited Members

using menu_item_collection
 Represents a collection of menu_item objects.
static constexpr xtd::int32 find_handle
 Specifies that the find_menu_item(int32, intptr) method should search for a handle.
static constexpr xtd::int32 find_shortcut
 Specifies that the find_menu_item(int32, intptr) method should search for a shortcut.
auto handle () const noexcept -> xtd::intptr
 Gets a value representing the window handle for the menu.
auto mdi_list_item () const noexcept -> const xtd::forms::menu_item &
 Gets a value indicating the menu_item that is used to display a list of multiple document interface (MDI) child forms.
auto menu_items () const noexcept -> const menu_item_collection &
 Gets a value indicating the collection of menu_item objects associated with the menu.
auto menu_items () noexcept -> menu_item_collection &
 Gets a value indicating the collection of menu_item objects associated with the menu.
auto menu_items (const menu_item_collection &value) -> menu &
 Sets a value indicating the collection of menu_item objects associated with the menu.
auto name () const noexcept -> const xtd::string &
 Gets the name of the menu.
auto name (const xtd::string &value) -> menu &
 Sets the name of the menu.
auto tag () const noexcept -> const xtd::any_object &
 Gets user-defined data associated with the control.
auto tag (const xtd::any_object &value) -> menu &
 Sets user-defined data associated with the control.
auto equals (const xtd::object &obj) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
auto equals (const menu &other) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
auto get_hash_code () const noexcept -> xtd::usize override
 Serves as a hash function for a particular type.
auto get_context_menu () const noexcept -> std::optional< xtd::ref< xtd::forms::context_menu > >
 Gets the context_menu that contains this menu.
auto get_main_menu () const noexcept -> std::optional< xtd::ref< xtd::forms::main_menu > >
 Gets the main_menu that contains this menu.
virtual auto merge_menu (const menu &menu_src) -> void
 Merges the MenuItem objects of one menu with the current menu.
 object ()=default
 Create a new instance of the ultimate base class object.
virtual auto get_type () const noexcept -> type_object
 Gets the type of the current instance.
template<typename object_t>
auto memberwise_clone () const -> xtd::unique_ptr_object< object_t >
 Creates a shallow copy of the current object.
virtual auto equals (const menu &) const noexcept -> bool=0
 Indicates whether the current object is equal to another object of the same type.
template<typename object_a_t, typename object_b_t>
static auto equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are considered equal.
template<typename object_a_t, typename object_b_t>
static auto reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are the same instance.
 menu ()
 Initializes a new instance of the Menu class.
 menu (const menu_item_collection &items)
 Initializes a new instance of the Menu class.
auto clone_menu (const menu &menu_src) -> void
 Copies the menu that is passed as a parameter to the current menu.
 component ()
 Initialises a new instance of the component class.
virtual auto can_raise_events () const noexcept -> bool
 Gets a value indicating whether the component can raise an event.
auto design_mode () const noexcept -> bool
 Gets a value that indicates whether the component is currently in design mode.

Constructor & Destructor Documentation

◆ menu_item() [1/26]

xtd::forms::menu_item::menu_item ( )

Initializes a menu_item with a blank caption.

Remarks
Once you have created a blank menu_item using this constructor, you can use the properties and methods of the menu_item class to specify the appearance and behavior of your menu_item.

◆ menu_item() [2/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text)
explicit

Initializes a new instance of the menu_item class with a specified caption for the menu item.

Parameters
textThe caption for the menu item.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [3/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [4/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
const xtd::drawing::image & image )

Initializes a new instance of the class with a specified caption, and image menu item.

Parameters
textThe caption for the menu item.
imageA xtd::drawing::image menu item.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [5/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
const xtd::drawing::image & image,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, and image menu item, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
imageA xtd::drawing::image menu item.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [6/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::forms::menu_item_kind kind )

Initializes a new instance of the class with a specified caption, and kind the menu item.

Parameters
textThe caption for the menu item.
kindOne of the xtd::forms::menu_item_kind value.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [7/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::forms::menu_item_kind kind,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, kind the menu item, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
kindOne of the xtd::forms::menu_item_kind value.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [8/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
const xtd::drawing::image & image,
xtd::forms::menu_item_kind kind )

Initializes a new instance of the class with a specified caption, image menu item, and kind the menu item.

Parameters
textThe caption for the menu item.
imageA xtd::drawing::image menu item.
kindOne of the xtd::forms::menu_item_kind value.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [9/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
const xtd::drawing::image & image,
xtd::forms::menu_item_kind kind,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
imageA xtd::drawing::image menu item.
kindOne of the xtd::forms::menu_item_kind value.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [10/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::forms::menu_item_kind kind,
bool checked )

Initializes a new instance of the class with a specified caption, kind the menu item and checked.

Parameters
textThe caption for the menu item.
kindOne of the xtd::forms::menu_item_kind value.
checkedtrue if there is a check mark next to the menu item; otherwise, false. The default is false.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [11/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::forms::menu_item_kind kind,
bool checked,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, kind the menu item, checked, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
kindOne of the xtd::forms::menu_item_kind value.
checkedtrue if there is a check mark next to the menu item; otherwise, false. The default is false.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [12/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
const xtd::drawing::image & image,
xtd::forms::menu_item_kind kind,
bool checked )

Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, and checked.

Parameters
textThe caption for the menu item.
imageA xtd::drawing::image menu item.
kindOne of the xtd::forms::menu_item_kind value.
checkedtrue if there is a check mark next to the menu item; otherwise, false. The default is false.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [13/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
const xtd::drawing::image & image,
xtd::forms::menu_item_kind kind,
bool checked,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, image menu item, kind the menu item, checked, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
imageA xtd::drawing::image menu item.
kindOne of the xtd::forms::menu_item_kind value.
checkedtrue if there is a check mark next to the menu item; otherwise, false. The default is false.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [14/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click )

Initializes a new instance of the class with a specified caption and event handler for the Click event of the menu item.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [15/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, event handler, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [16/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click,
const xtd::drawing::image & image )

Initializes a new instance of the class with a specified caption, event handler, and image menu item.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
imageA xtd::drawing::image menu item.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [17/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click,
const xtd::drawing::image & image,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, event handler, and image menu item, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
imageA xtd::drawing::image menu item.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [18/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click,
xtd::forms::menu_item_kind kind )

Initializes a new instance of the class with a specified caption, event handler, and kind the menu item.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
kindOne of the xtd::forms::menu_item_kind value.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [19/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click,
xtd::forms::menu_item_kind kind,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, event handler, kind the menu item, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
kindOne of the xtd::forms::menu_item_kind value.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [20/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click,
const xtd::drawing::image & image,
xtd::forms::menu_item_kind kind )

Initializes a new instance of the class with a specified caption, event handler, image menu item, and kind the menu item.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
imageA xtd::drawing::image menu item.
kindOne of the xtd::forms::menu_item_kind value.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [21/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click,
const xtd::drawing::image & image,
xtd::forms::menu_item_kind kind,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
imageA xtd::drawing::image menu item.
kindOne of the xtd::forms::menu_item_kind value.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [22/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click,
xtd::forms::menu_item_kind kind,
bool checked )

Initializes a new instance of the class with a specified caption, event handler, kind the menu item and checked.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
kindOne of the xtd::forms::menu_item_kind value.
checkedtrue if there is a check mark next to the menu item; otherwise, false. The default is false.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [23/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click,
xtd::forms::menu_item_kind kind,
bool checked,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, event handler, kind the menu item, checked, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
kindOne of the xtd::forms::menu_item_kind value.
checkedtrue if there is a check mark next to the menu item; otherwise, false. The default is false.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [24/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click,
const xtd::drawing::image & image,
xtd::forms::menu_item_kind kind,
bool checked )

Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, and checked.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
imageA xtd::drawing::image menu item.
kindOne of the xtd::forms::menu_item_kind value.
checkedtrue if there is a check mark next to the menu item; otherwise, false. The default is false.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [25/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
xtd::event_handler on_click,
const xtd::drawing::image & image,
xtd::forms::menu_item_kind kind,
bool checked,
xtd::forms::shortcut shortcut )

Initializes a new instance of the class with a specified caption, event handler, image menu item, kind the menu item, checked, and associated shortcut key for the menu item.

Parameters
textThe caption for the menu item.
on_clickThe event_handler that handles the Click event for this menu item.
imageA xtd::drawing::image menu item.
kindOne of the xtd::forms::menu_item_kind value.
checkedtrue if there is a check mark next to the menu item; otherwise, false. The default is false.
shortcutOne of the xtd::forms::shortcut values.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ menu_item() [26/26]

xtd::forms::menu_item::menu_item ( const xtd::string & text,
const std::vector< menu_item_ref > & items )

Initializes a new instance of the class with a specified caption and an array of submenu items defined for the menu item.

Parameters
textThe caption for the menu item.
itemsAn array of menu_item objects that contains the submenu items for this menu item.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.
The items parameter enables you to assign an array of menu items to define a submenu of this menu item. Each item in the array can also have an array of menu items assigned to it. This enables you to create complete menu structures and assign them to the constructor for the menu item.

Member Function Documentation

◆ menu_id()

auto xtd::forms::menu_item::menu_id ( ) const -> xtd::intptr
nodiscardnoexcept

Gets a value indicating the Windows identifier for this menu item.

Returns
The Windows identifier for this menu item.

◆ checked() [1/2]

auto xtd::forms::menu_item::checked ( ) const -> bool
nodiscardnoexcept

Gets a value indicating whether a check mark appears next to the text of the menu item.

Returns
true if there is a check mark next to the menu item; otherwise, false. The default is false.

◆ checked() [2/2]

auto xtd::forms::menu_item::checked ( bool value) -> menu_item &

Sets a value indicating whether a check mark appears next to the text of the menu item.

Parameters
valuetrue if there is a check mark next to the menu item; otherwise, false. The default is false.
Returns
Current menu_item.

◆ enabled() [1/2]

auto xtd::forms::menu_item::enabled ( ) const -> bool
nodiscardnoexcept

Gets a value indicating whether the menu item is enabled.

Returns
true if the menu item is enabled; otherwise, false. The default is true.

◆ enabled() [2/2]

auto xtd::forms::menu_item::enabled ( bool value) -> menu_item &

Gets a value indicating whether the menu item is enabled.

Parameters
valuetrue if the menu item is enabled; otherwise, false. The default is true.
Returns
Current menu_item.

◆ is_parent()

auto xtd::forms::menu_item::is_parent ( ) const -> bool
nodiscardoverridevirtualnoexcept

Gets a value indicating whether this menu contains any menu items.

Returns
true if this menu contains menu_item objects; otherwise, false. The default is false.

Reimplemented from xtd::forms::menu.

◆ kind() [1/2]

auto xtd::forms::menu_item::kind ( ) const -> xtd::forms::menu_item_kind
nodiscardnoexcept

Gets a value that represents the kind of menu item.

Returns
One of the xtd::forms::menu_item_kind value.

◆ kind() [2/2]

auto xtd::forms::menu_item::kind ( xtd::forms::menu_item_kind value) -> menu_item &

Sets a value that represents the kind of menu item.

Parameters
valueOne of the xtd::forms::menu_item_kind value.
Returns
Current menu_item.

◆ shortcut() [1/2]

auto xtd::forms::menu_item::shortcut ( ) const -> xtd::forms::shortcut
nodiscardnoexcept

Gets a value indicating the shortcut key associated with the menu item.

Returns
One of the xtd::forms::shortcut values. The default is xtd::forms::shortcut::none.

◆ shortcut() [2/2]

auto xtd::forms::menu_item::shortcut ( xtd::forms::shortcut value) -> menu_item &

Sets a value indicating the shortcut key associated with the menu item.

Parameters
valueOne of the xtd::forms::shortcut values. The default is xtd::forms::shortcut::none.
Returns
Current menu_item.

◆ text() [1/2]

auto xtd::forms::menu_item::text ( ) const -> const xtd::string &
nodiscardnoexcept

Gets a value indicating the caption of the menu item.

Returns
The text caption of the menu item.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ text() [2/2]

auto xtd::forms::menu_item::text ( const xtd::string & value) -> menu_item &

Sets a value indicating the caption of the menu item.

Parameters
valueThe text caption of the menu item.
Returns
Current menu_item.
Remarks
When you specify a caption for your menu item with the text parameter, you can also specify an access key by placing an '&' before the character to be used as the access key. For example, to specify the "F" in "File" as an access key, you would specify the caption for the menu item as "&File". You can use this feature to provide keyboard navigation for your menus.
Setting the text parameter to "-" causes your menu item to be displayed as a separator (a horizontal line) rather than a standard menu item.

◆ perform_click()

void xtd::forms::menu_item::perform_click ( )

Generates a xtd::forms::menu_item::click event for the xtd::forms::menu_item, simulating a click by a user.

Remarks
You can use this menu to activate a menu item through code without passing any event information. For example, if you want to activate a menu item based on an action that occurs in your application, you can call the xtd::forms::menu_item::perform_click method for that xtd::forms::menu_item.

◆ to_string()

auto xtd::forms::menu_item::to_string ( ) const -> xtd::string
nodiscardoverridevirtualnoexcept

Returns a string that represents the menu control.

Returns
A string that represents the current menu.
Remarks
The to_string method returns a string that includes the type and the number of items in the menu_items property of the control.

Reimplemented from xtd::forms::menu.

◆ create_menu_handle()

auto xtd::forms::menu_item::create_menu_handle ( ) -> xtd::intptr
overrideprotectedvirtual

Creates a new handle to the Menu.

Returns
A handle to the menu if the method succeeds; otherwise, 0.

Implements xtd::forms::menu.

◆ destroy_menu_handle()

auto xtd::forms::menu_item::destroy_menu_handle ( xtd::intptr handle) -> void
overrideprotectedvirtual

Destroys the handle to the Menu.

Parameters
handleA handle to the menu.

Reimplemented from xtd::forms::menu.

◆ on_click()

virtual auto xtd::forms::menu_item::on_click ( const event_args & e) -> void
protectedvirtual

Raises the Click event.

Parameters
eAn xtd::event_args that contains the event data.
Remarks
Raising an event invokes the event handler through a delegate.

◆ on_item_added()

auto xtd::forms::menu_item::on_item_added ( xtd::usize pos,
menu_item_ref item ) -> void
overrideprotectedvirtual

Reimplemented from xtd::forms::menu.

◆ on_item_removed()

auto xtd::forms::menu_item::on_item_removed ( xtd::usize pos,
menu_item_ref item ) -> void
overrideprotectedvirtual

Reimplemented from xtd::forms::menu.

Member Data Documentation

◆ click

xtd::event<menu_item, xtd::event_handler> xtd::forms::menu_item::click

Occurs when the menu item is clicked or selected using a shortcut key or access key defined for the menu item.

Remarks
The xtd::forms::menu_item::click event occurs when this xtd::forms::menu_item is clicked by the user. This event also occurs if the user selects the menu item using the keyboard and presses the Enter key. It can also occur if an access key or shortcut key is pressed that is associated with the xtd::forms::menu_item.
For more information about handling events, see Handling and Raising Events.

The documentation for this class was generated from the following file: