Class A is a ruby file generated from XRC via xrcise. Class B is a
child class that inherits from class A, and subsequently is where I have
my event hook-ups defined (just in case I need to generate class A from
XRC again, I don’t want the event code overwritten).
My question is about the syntax for the event hookups. Why does the
code below work the way it does?
class B < A
def initialize
super
evt_menu(@m_menuAbout) { | event | onAbout(event) } #this works
evt_menu(self.m_menuAbout) { | event | onAbout2(event) } #also works
evt_menu(@m_menuAbout) { :onAbout3 } #does not work
end
def onAbout(event)
puts ‘You clicked the About menu’
end
def onAbout2(event)
puts ‘You clicked the About menu’
end
def onAbout3
puts ‘You would have cliked the About menu but the code doesn’t get
here’
end
end
Kind of new to ruby, so I’m not sure why I need to include the | event |
syntax for the event hookup. Any explainations? Thanks!