Class: Wx::MenuEvent

Inherits:
Event show all
Defined in:
lib/wx/doc/gen/events.rb

Overview

This class is used for a variety of menu-related events.

Note that these do not include menu command events, which are handled using CommandEvent objects. Events of this class are generated by both menus that are part of a MenuBar, attached to Frame, and popup menus shown by Window#popup_menu. They are sent to the following objects until one of them handles the event:

  • The menu object itself, as returned by #get_menu, if any.

  • The MenuBar to which this menu is attached, if any.

  • The window associated with the menu, e.g. the one calling PopupMenu() for the popup menus.

  • The top level parent of that window if it’s different from the window itself.

This is similar to command events generated by the menu items, but, unlike them, MenuEvent are only sent to the window itself and its top level parent but not any intermediate windows in the hierarchy. The default handler for EVT_MENU_HIGHLIGHT in Frame displays help text in the status bar, see Frame#set_status_bar_pane.

Events using this class

The following event-handler methods redirect the events to member method or handler blocks for MenuEvent events. Event handler methods:

  • EvtHandler#evt_menu_open(meth = nil, &block): A menu is about to be opened. On Windows, this is only sent once for each navigation of the menubar (up until all menus have closed).

  • EvtHandler#evt_menu_close(meth = nil, &block): A menu has been just closed. Notice that this event is currently being sent before the menu selection (EVT_MENU) event, if any.

  • EvtHandler#evt_menu_highlight(id, meth = nil, &block): The menu item with the specified id has been highlighted: used to show help prompts in the status bar by Frame

  • EvtHandler#evt_menu_highlight_all(meth = nil, &block): A menu item has been highlighted, i.e. the currently selected menu item has changed.

Category: Events

See Also:

Instance Method Summary collapse

Methods inherited from Event

#clone, #get_event_category, #get_event_object, #get_event_type, #get_id, #get_skipped, #get_timestamp, #is_command_event, #resume_propagation, #set_event_object, #set_event_type, #set_id, #set_timestamp, #should_propagate, #skip, #stop_propagation

Methods inherited from Object

#clone, #dup, #is_same_as, #un_share

Constructor Details

#initialize(type = Wx::EVT_NULL, id = 0, menu = nil) ⇒ Wx::MenuEvent

Constructor.

Parameters:

  • type (Wx::GenericCollapsiblePane::EventType) (defaults to: Wx::EVT_NULL)
  • id (Integer) (defaults to: 0)
  • menu (Wx::Menu) (defaults to: nil)


1701
# File 'lib/wx/doc/gen/events.rb', line 1701

def initialize(type=Wx::EVT_NULL, id=0, menu=nil) end

Instance Method Details

#get_menuWx::Menu Also known as: menu

Returns the menu which is being opened or closed, or the menu containing the highlighted item.

Note that the returned value can be NULL if the menu being opened doesn’t have a corresponding Wx::Menu, e.g. this happens when opening the system menu in WXMSW port.

Remark:

Since 3.1.3 this function can be used with OPEN, CLOSE and HIGHLIGHT events. Before 3.1.3, this method can only be used with the OPEN and CLOSE events.

Returns:



1713
# File 'lib/wx/doc/gen/events.rb', line 1713

def get_menu; end

#get_menu_idInteger Also known as: menu_id

Returns the menu identifier associated with the event.

This method should be only used with the HIGHLIGHT events.

Returns:

  • (Integer)


1720
# File 'lib/wx/doc/gen/events.rb', line 1720

def get_menu_id; end

#is_popupBoolean Also known as: popup?

Returns true if the menu which is being opened or closed is a popup menu, false if it is a normal one.

This method should only be used with the OPEN and CLOSE events.

Returns:

  • (Boolean)


1727
# File 'lib/wx/doc/gen/events.rb', line 1727

def is_popup; end