### In Files

- wx/classes/evthandler.rb

### Parent

Wx::Object

### Methods

- const_to_name
- event_class_for_type
- event_name_for_type
- event_type_for_name
- evt_mouse_events
- evt_scrollwin
- register_class
- register_event_type

### Files

- wxruby2.lib

### Class Index

Quicksearch

- Wx
- Wx::AcceleratorTable
- Wx::Animation
- Wx::App
- Wx::ArtProvider
- Wx::AuiNotebook
- Wx::Bitmap
- Wx::BusyCursor
- Wx::CheckListBox
- Wx::Choice
- Wx::ClientDC
- Wx::Clipboard
- Wx::Colour
- Wx::ComboBox
- Wx::CommandEvent
- Wx::ControlWithItems
- Wx::DC
- Wx::Event
- Wx::EvtHandler
- Wx::Font
- Wx::Grid
- Wx::HelpController
- Wx::HelpControllerHelpProvider
- Wx::HelpProvider
- Wx::HtmlHelpController
- Wx::HtmlWindow
- Wx::Icon
- Wx::IconBundle
- Wx::Image
- Wx::ImageList
- Wx::KeywordConstructor
- Wx::KeywordConstructor::ClassMethods
- Wx::ListBox
- Wx::ListCtrl
- Wx::Locale
- Wx::MediaCtrl
- Wx::Menu
- Wx::MenuItem
- Wx::Notebook
- Wx::Object
- Wx::PaintDC
- Wx::Point
- Wx::PreviewFrame
- Wx::Rect
- Wx::RichTextCtrl
- Wx::SimpleHelpProvider
- Wx::Size
- Wx::Sizer
- Wx::Sound
- Wx::StandardPaths
- Wx::TextCtrl
- Wx::TextUrlEvent
- Wx::Timer
- Wx::ToolBar
- Wx::ToolBarTool
- Wx::TreeCtrl
- Wx::Window
- Wx::XmlResource
- Rumix
- Rumix::Application
- Rumix::Config
- Rumix::Registry
- Rumix::Widget
- Rumix::Widget::CheckOptionPanel
- Rumix::Widget::OptionItem
- Rumix::Widget::OptionPanel
- Rumix::Widget::RadioOptionPanel
- Rumix::Widget::TitleText
- ROpt
- ROpt::ArgumentParser
- ROpt::ParseResult
- Uconv
- Uconv::Error
- Enumerable
- File
- Ini
- Kernel
- Module
- Object
- Pathname
- WxConstructor
- WxRubyStyleAccessors

No matching classes.

# Wx::EvtHandler

All classes which are capable of handling events inherit from EvtHandler. This includes all Wx::Window subclasses and Wx::App.

### Constants

EventType
  EventType is an internal class that’s used to set up event handlers and mappings.
  - ‘name’ is the name of the event handler method in ruby
  - ‘arity’ is the number of id arguments that method should accept
  - ‘const’ is the Wx EventType constant that identifies the event
  - ‘evt_class’ is the WxRuby event class which is passed to the event

         handler block

  NB: Some event types currently pass a Wx::Event into the event handler block; when the appropriate classes are added to wxRuby, the binding can be updated here.

EVENT_TYPE_CLASS_MAP
  Fast look-up hash to map event type ids to ruby event classes
EVENT_NAME_TYPE_MAP
  Hash to look up EVT constants from symbol names of evt handler methods; used internally by disconnect (see EvtHandler.i)
EVENT_DEFINITIONS
  All StyledTextCtrl (Scintilla) events with prefix EVT_STC are dealt with in the separate styledtextctrl.rb file.

  All MediaCtrl events with prefix EVT_MEDIA are dealt with in the separate mediactrl.rb file

### Public Class Methods

const_to_name(int_val) click to toggle source

Given an integer value `int_val`, returns the name of the EVT_xxx constant which points to it. Mainly useful for debugging.

    # File wx/classes/evthandler.rb, line 53
      def self.const_to_name(int_val)
        Wx::constants.grep(/^EVT/).find do | c_name |
          Wx::const_get(c_name) == int_val
        end
      end

event_class_for_type(id) click to toggle source

Given a Wx EventType id (eg Wx::EVT_MENU), returns a WxRuby Event class which should be passed to event handler blocks. The actual EVT_XXX constants themselves are in the compiled library, defined in swig/classes/Event.i

    # File wx/classes/evthandler.rb, line 28
      def self.event_class_for_type(id)
        if evt_klass = EVENT_TYPE_CLASS_MAP[id]
          return evt_klass
        else
          if Wx::DEBUG
            warn "No event class defined for event type #{id}"
          end
          return Wx::Event
        end
      end

event_name_for_type(name) click to toggle source

Given the Integer constant Wx::EVT_XXX, returns the convenience handler method name associated with that type of event.

    # File wx/classes/evthandler.rb, line 47
      def self.event_name_for_type(name)
        EVENT_NAME_TYPE_MAP.index(name)
      end

event_type_for_name(name) click to toggle source

Given the symbol name of an evt_xxx handler method, returns the Integer Wx::EVT_XXX constant associated with that handler.

    # File wx/classes/evthandler.rb, line 41
      def self.event_type_for_name(name)
        EVENT_NAME_TYPE_MAP[name]
      end

register_class( klass, konstant = nil, meth = nil, arity = nil) click to toggle source

Public method to register the mapping of a custom event type `konstant` (which should be a unique integer; one will be created if not supplied) to a custom event class `klass`. If `meth` and `arity` are given, a convenience evt_handler method called `meth` will be created, which accepts `arity` arguments.

    # File wx/classes/evthandler.rb, line 64
      def self.register_class( klass, konstant = nil,
                               meth = nil, arity = nil)
        konstant ||= Wx::Event.new_event_type
        unless klass < Wx::Event
          Kernel.raise TypeError, "Event class should be a subclass of Wx::Event"
        end
        ev_type = EventType.new(meth, arity, konstant, klass)
        register_event_type(ev_type)
        return konstant
      end

register_event_type(ev_type) click to toggle source

Registers the event type `ev_type`, which should be an instance of the Struct class +Wx::EvtHandler::EventType+. This sets up the mapping of events of that type (identified by integer id) to the appropriate ruby event class, and defines a convenience evt_xxx instance method in the class EvtHandler.

    # File wx/classes/evthandler.rb, line 80
      def self.register_event_type(ev_type)
        # set up the event type mapping
        EVENT_TYPE_CLASS_MAP[ev_type.const] = ev_type.evt_class
        EVENT_NAME_TYPE_MAP[ev_type.name.intern] = ev_type.const

        unless ev_type.arity and ev_type.name
          return
        end

        # set up the evt_xxx method
        case ev_type.arity
        when 0 # events without an id
          class_eval %Q|
            def #{ev_type.name}(meth = nil, &block)
              handler = acquire_handler(meth, block)
              connect(Wx::ID_ANY, Wx::ID_ANY, #{ev_type.const}, &handler)
            end |
        when 1 # events with an id
          class_eval %Q|
            def #{ev_type.name}(id, meth = nil, &block)
              handler = acquire_handler(meth, block)
              id  = acquire_id(id)
              connect(id, Wx::ID_ANY, #{ev_type.const}, &handler)
            end |
        when 2 # events with id range
          class_eval %Q|
            def #{ev_type.name}(first_id, last_id, meth = nil, &block)
              handler  = acquire_handler(meth, block)
              first_id = acquire_id(first_id)
              last_id  = acquire_id(last_id)
              connect( first_id, last_id, #{ev_type.const}, &handler)
            end |
        end
      end

### Public Instance Methods

evt_mouse_events(&block) click to toggle source

convenience evt_handler to listen to all mouse events

    # File wx/classes/evthandler.rb, line 984
      def evt_mouse_events(&block)
        evt_left_down(&block)
        evt_left_up(&block)
        evt_middle_down(&block)
        evt_middle_up(&block)
        evt_right_down(&block)
        evt_right_up(&block)
        evt_motion(&block)
        evt_left_dclick(&block)
        evt_middle_dclick(&block)
        evt_right_dclick(&block)
        evt_leave_window(&block)
        evt_enter_window(&block)
        evt_mousewheel(&block)
      end

evt_scrollwin(&block) click to toggle source

convenience evt handler to listen to all scrollwin events

    # File wx/classes/evthandler.rb, line 1001
      def evt_scrollwin(&block)
        evt_scrollwin_top(&block)
        evt_scrollwin_bottom(&block)
        evt_scrollwin_lineup(&block)
        evt_scrollwin_linedown(&block)
        evt_scrollwin_pageup(&block)
        evt_scrollwin_pagedown(&block)
        evt_scrollwin_thumbtrack(&block)
        evt_scrollwin_thumbrelease(&block)
      end

Disabled; run with $DEBUG to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.