Module: Apotomo::EventMethods::ClassMethods
- Defined in:
- lib/apotomo/widget/event_methods.rb
Instance Method Summary collapse
-
#responds_to_event(*options) ⇒ Object
Instructs the widget to look out for
typeevents.
Instance Method Details
#responds_to_event(*options) ⇒ Object
Instructs the widget to look out for type events. If an appropriate event starts from or passes the widget, the defined trigger state is executed.
class MouseWidget < Apotomo::Widget
responds_to_event :squeak
def squeak(evt)
update
end
Calls #squeak when a :squeak event is encountered.
Options
Any option except the event type is optional.
:with => state-
executes
state, defaults totype.responds_to_event :squeak, :with => :chirpwill invoke the
#chirpstate method. :on => id-
execute the trigger state on another widget.
responds_to_event :squeak, :on => :catwill invoke the
#squeakstate on the:catwidget. :from => id-
executes the state only if the event origins from
id.responds_to_event :squeak, :from => :kidwill invoke the
#squeakstate if:kidtriggered and if:kidis a decendent of the current widget. :passing => id-
attaches the observer to another widget. Useful if you want to catch bubbling events in
root.responds_to_event :squeak, :passing => :rootwill invoke the state on the current widget if the event passes
:root(which is highly probable).
Inheritance
Note that the observers are inherited. This allows deriving a widget class without having to redefine the responds_to_event blocks.
71 72 73 |
# File 'lib/apotomo/widget/event_methods.rb', line 71 def responds_to_event(*) << end |