Browse Subversion Repository
Contents of /event_manager.rb
Parent Directory
| Revision Log
Revision 2 -
( show annotations)
( download)
Tue Apr 3 18:03:39 2007 UTC
(16 years, 11 months ago)
by bluedwarf
File size: 860 byte(s)
* Added Gtk+-2.0 support.
* Implement event handlers and action manager.
| 1 |
|
| 2 |
require "event_handler/event_handler.rb" |
| 3 |
|
| 4 |
module Edmaru |
| 5 |
|
| 6 |
#The controller to manage event handlers. |
| 7 |
class EventManager |
| 8 |
|
| 9 |
#Create an event manager. |
| 10 |
# |
| 11 |
#=== Return |
| 12 |
#An initialized manager. |
| 13 |
def initialize |
| 14 |
@current_handler = nil |
| 15 |
end |
| 16 |
|
| 17 |
#Set the handler whose name is _handler_name_ as the current handler |
| 18 |
# |
| 19 |
#=== Argument |
| 20 |
#_handler_ :: An instance of Edmaru::EventHandler to be added. |
| 21 |
def set_current_handler(handler) |
| 22 |
@current_handler = handler |
| 23 |
end |
| 24 |
|
| 25 |
#Make the current handler to handle the specified event. |
| 26 |
# |
| 27 |
#=== Argument |
| 28 |
#_event_name_ :: A String instance representing the event name. |
| 29 |
def handle(event_name) |
| 30 |
if @current_handler != nil |
| 31 |
@current_handler.handle(event_name) |
| 32 |
else |
| 33 |
raise "Event handler has not been registered yet!" |
| 34 |
end |
| 35 |
end |
| 36 |
end |
| 37 |
end |
|