From: Zach Dennis Date: 2004-11-13T07:44:26+09:00 Subject: Re: Another design question... Joe Van Dyk wrote: > >How would the AirplanePopupMenu object know what Airplane object's method to >use when the user selects an item from the popup menu? > > > You could couple Airplane and AirplanePopupMenu. This would allow AirplanePopupMenu to know about the methods on the Airplane class. If there are going to be more then one Airplane object at a time, then allow for the AirplaneMenu to be passed an instance of Airplane. For example: class Airplane def current_speed return 290 #speed in mph? end end class AirplanePopupMenu AP_SPEED = 11 def get_menu( airplane, *args ) args.each{ |arg| case arg when AP_SPEED #process the code to add a MenuItem for speed here to your menu menu_item = Menuitem.new menu_item.set_label( airplane.speed ) @mymenu.add_menu_item( menu_item ) else end return @mymenu end end I do not use GTK and I haven't used Ruby/Tk in a long while so I won't even attempt to have the code make sense like that. I'll leave the transitioning of code up to you. Zach