wxRuby Documentation Home

Wx::CommandEvent

This event class contains information about command events, which originate from a variety of simple controls such as buttons, checkboxes, lists and menus. It controls which contain multiple items with string labels, it can be used to determine which specific item has been used (see get_index, and whether a selection or deselection has taken place (see is_selection).

More complex controls, such as TreeCtrl, have separate command event classes.

Custom event classes

If implementing completely new custom controls in Ruby, event types associated with that control should normally inherit from CommandEvent. If you wish to associate data with instances of your custom Event class, you should do so using set_client_data. Normal instance variables are not preserved so will be set to nil when they are handled by event handler methods.

See the “event” sample included with wxRuby for an example.

Derived from

Event

Event table macros

To handle command events, use these event handler methods to set up a block to receive the event. All of these event handler methods require that the control whose events are being listened for be identified – see the event handling overview for more information.

evt_command(id) { | event | ... } Process a command, supplying the window identifier,command event identifier, and member function.
evt_command_range(id1, id2) { | event | ... } Process a command for a rangeof window identifiers, supplying the minimum and maximum window identifiers,command event identifier, and member function.
evt_button(id) { | event | ... } Process a EVT_COMMAND_BUTTON_CLICKED command,which is generated by a Button control.
evt_checkbox(id) { | event | ... } Process a EVT_COMMAND_CHECKBOX_CLICKED command,which is generated by a CheckBox control.
evt_choice(id) { | event | ... } Process a EVT_COMMAND_CHOICE_SELECTED command,which is generated by a Choice control.
evt_combobox(id) { | event | ... } Process a EVT_COMMAND_COMBOBOX_SELECTED command,which is generated by a ComboBox control.
evt_listbox(id) { | event | ... } Process a EVT_COMMAND_LISTBOX_SELECTED command,which is generated by a ListBox control.
evt_listbox_dclick(id) { | event | ... } Process a EVT_COMMAND_LISTBOX_DOUBLECLICKED command,which is generated by a ListBox control.
evt_menu(id) { | event | ... } Process a EVT_COMMAND_MENU_SELECTED command,which is generated by a menu item.
evt_menu_range(id1, id2) { | event | ... } Process a EVT_COMMAND_MENU_RANGE command,which is generated by a range of menu items.
evt_context_menu() { | event | ... } Process the event generatedwhen the user has requested a popup menu to appear by pressing a specialkeyboard key (under Windows) or by right clicking the mouse.
evt_radiobox(id) { | event | ... } Process a EVT_COMMAND_RADIOBOX_SELECTED command,which is generated by a RadioBox control.
evt_radiobutton(id) { | event | ... } Process a EVT_COMMAND_RADIOBUTTON_SELECTED command,which is generated by a RadioButton control.
evt_scrollbar(id) { | event | ... } Process a EVT_COMMAND_SCROLLBAR_UPDATED command,which is generated by a ScrollBar control. This is provided for compatibility only;more specific scrollbar event macros should be used instead (see ScrollEvent).
evt_slider(id) { | event | ... } Process a EVT_COMMAND_SLIDER_UPDATED command,which is generated by a Slider control.
evt_text(id) { | event | ... } Process a EVT_COMMAND_TEXT_UPDATED command,which is generated by a TextCtrl control.
evt_text_enter(id) { | event | ... } Process a EVT_COMMAND_TEXT_ENTER command,which is generated by a TextCtrl control. Note that you must useTE_PROCESS_ENTER flag when creating the control if you want it to generatesuch events.
evt_text_maxlen(id) { | event | ... } Process a EVT_COMMAND_TEXT_MAXLEN command,which is generated by a TextCtrl control when the user tries to enter morecharacters into it than the limit previously set with set_max_length.
evt_togglebutton(id) { | event | ... } Process a EVT_COMMAND_TOGGLEBUTTON_CLICKED event.
evt_tool(id) { | event | ... } Process a EVT_COMMAND_TOOL_CLICKED event(a synonym for EVT_COMMAND_MENU_SELECTED). Pass the id of the tool.
evt_tool_range(id1, id2) { | event | ... } Process a EVT_COMMAND_TOOL_CLICKED eventfor a range of identifiers. Pass the ids of the tools.
evt_tool_rclicked(id) { | event | ... } Process a EVT_COMMAND_TOOL_RCLICKED event.Pass the id of the tool.
evt_tool_rclicked_range(id1, id2) { | event | ... } Process a EVT_COMMAND_TOOL_RCLICKED eventfor a range of ids. Pass the ids of the tools.
evt_tool_enter(id) { | event | ... } Process a EVT_COMMAND_TOOL_ENTER event.Pass the id of the toolbar itself. The value of CommandEvent::GetSelection is the tool id, or -1 if the mouse cursor has moved off a tool.
evt_command_left_click(id) { | event | ... } Process a EVT_COMMAND_LEFT_CLICK command,which is generated by a control (Windows 95 and NT only).
evt_command_left_dclick(id) { | event | ... } Process a EVT_COMMAND_LEFT_DCLICK command,which is generated by a control (Windows 95 and NT only).
evt_command_right_click(id) { | event | ... } Process a EVT_COMMAND_RIGHT_CLICK command,which is generated by a control (Windows 95 and NT only).
evt_command_set_focus(id) { | event | ... } Process a EVT_COMMAND_SET_FOCUS command,which is generated by a control (Windows 95 and NT only).
evt_command_kill_focus(id) { | event | ... } Process a EVT_COMMAND_KILL_FOCUS command,which is generated by a control (Windows 95 and NT only).
evt_command_enter(id) { | event | ... } Process a EVT_COMMAND_ENTER command,which is generated by a control.

Methods

CommandEvent.new

CommandEvent.new(TYPE commandEventType = 0,  Integer id = 0)

Constructor.

CommandEvent#get_client_data

Object get_client_data()

Returns extra data associated with the event. This may be in-built information from wxRuby for standard event types, or, for custom event types, additional data in the form of any normal Ruby object.

For in-built events from wxRuby, this method returns the integer index of the particular item being selected in a listbox, choice or radiobox selection, or the item being checked in checklistbox.

This method is only valid when an item is being selected, not when an item is being deselected. Whilst the correct value may be returned on some platforms (eg Windows), the value may be empty on others (eg GTK) when a deselection is taking place.

CommandEvent#get_index

Integer get_index()

Returns the integer index of the particular item being selected in a listbox, choice or radiobox selection, or the item being checked in checklistbox.

This method is only valid when an item is being selected, not when an item is being deselected. Whilst the correct value may be returned on some platforms (eg Windows), the value may be empty on others (eg GTK) when a deselection is taking place.

CommandEvent#get_int

Integer get_int()

This is a deprecated alias for get_index use that method by preference.

CommandEvent#get_selection

Integer get_selection()

Returns item index for a listbox or choice selection event (not valid for a deselection). This is an alias for get_index

CommandEvent#get_string

String get_string()

Returns the string label of the item being selected or checked in a listbox, choice or similar control with multiple items.

This method is only valid when an item is being selected, not when an item is being deselected. Whilst the correct value may be returned on some platforms (eg Windows), the value may be empty on others (eg GTK) when a deselection is taking place.

CommandEvent#is_checked

Boolean is_checked()

This method can be used with checkbox and menu events: for the checkboxes, the method returns true for a selection event and false for a deselection one. For the menu events, this method indicates if the menu item just has become checked or unchecked (and thus only makes sense for checkable menu items).

Note that this method is not useful for events coming from a CheckListBox you must check the checked state of the relevant item in the control directly using the is_checked method in that class.

CommandEvent#is_selection

Boolean is_selection()

For a listbox or similar event, returns true if it is a selection, false if it is a deselection.

CommandEvent#set_client_data

set_client_data((arg-type) clientData)

Sets the client data for this event. This method is never normally called on standard events generated by normal wxRuby controls. However, it is useful when writing custom event classes to associate additional information with the event.

CommandEvent#set_extra_long

set_extra_long(Integer extraLong)

Sets the m_extraLong attribute; this is used in the case of selection events to determine whether it is a selection (when the value should be 1) or a deselection (when it should be 0).

CommandEvent#set_int

set_int(Integer intCommand)

In the case of selection and checking events from controls with multiple items, sets the index of item being selected; in the case of checkboxes, should be 1 if the control is being checked, or 0 if being unchecked.

CommandEvent#set_string

set_string(String string)

Sets the string of the item being selected.

[This page automatically generated from the Textile source at Wed Sep 09 02:21:03 +0100 2009]