All classes which are capable of handling events inherit from EvtHandler. This includes all Wx::Window subclasses and Wx::App.
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.
All MediaCtrl events with prefix EVT_MEDIA are dealt with in the separate mediactrl.rb file
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
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
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
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
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
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
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
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.
Generated with the Darkfish Rdoc Generator 1.1.6.